连接关闭,检测到EOF

时间:2016-09-09 09:40:30

标签: java https weblogic httpurlconnection httpsurlconnection

我想将一些json数据从启用ADFS SSO的weblogic服务器发布到https url(jetty服务器),但我得到以下异常

    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)

以下是摘录

        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();

这适用于http url,即没有启用SSL

1 个答案:

答案 0 :(得分:2)

如果我们使用的是Weblogic服务器,我们必须定义:

phantom

...在Server Domain内的类路径中。

这将告诉weblogic服务器使用Sun Http Handler而不是自己安装。