Connection closed, EOF detected

纵然是瞬间 提交于 2019-12-11 05:33:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!