问题
I want to post some json data from ADFS SSO enabled weblogic server to an https url(jetty server) but I am getting the below exception
java.io.IOException: Connection closed, EOF detected
at weblogic.socket.JSSEFilterImpl.handleUnwrapResults(JSSEFilterImpl.java:637)
at weblogic.socket.JSSEFilterImpl.unwrapAndHandleResults(JSSEFilterImpl.java:515)
at weblogic.socket.JSSEFilterImpl.doHandshake(JSSEFilterImpl.java:96)
at weblogic.socket.JSSEFilterImpl.doHandshake(JSSEFilterImpl.java:75)
at weblogic.socket.JSSEFilterImpl.write(JSSEFilterImpl.java:448)
at weblogic.socket.JSSESocket$JSSEOutputStream.write(JSSESocket.java:93)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at java.io.FilterOutputStream.flush(FilterOutputStream.java:140)
at weblogic.net.http.HttpURLConnection.writeRequests(HttpURLConnection.java:192)
at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:433)
at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
Below is the snippet
URL urlObject = new URL(url);
HttpURLConnection httpConnection = (HttpURLConnection) urlObject.openConnection();
httpConnection.setRequestMethod("POST");
httpConnection.setDoOutput(true);
httpConnection.setDoInput(true);
httpConnection.addRequestProperty("Content-Type", "application/xml");
OutputStreamWriter writer = new OutputStreamWriter(httpConnection.getOutputStream());
writer.write(paramJSON.toString());
writer.flush();
String line;
StringBuffer buffer = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
while ((line = reader.readLine()) != null)
{
buffer.append(line);
}
writer.close();
reader.close();
int status = httpConnection.getResponseCode();
httpConnection.disconnect();
This is working with both http url i.e. without SSL enabled
回答1:
If we are using Weblogic server, we must define:
set JAVA_OPTIONS=%JAVA_OPTIONS% -DUseSunHttpHandler=true
...in the class path inside the Server Domain.
This will tell the weblogic server to use the Sun Http Handlers and not install its own.
来源:https://stackoverflow.com/questions/39408507/connection-closed-eof-detected