当我使用JAXRS调用rest API时,我收到了一个EOFException。
当我运行与独立Java应用程序相同时。它工作正常,我得到了回应。但是当我在Weblogic 10.3中执行时,我收到了EOFException。
代码段下方。
JAXRSClientFactoryBean jaxRSClientFactoryBean = new JAXRSClientFactoryBean(); jaxRSClientFactoryBean.setAddress( "https://api.testing.net:443/api/v1/Account?AccountId=9"); System.out.println(" URL: " + jaxRSClientFactoryBean.getAddress()); WebClient restClient = jaxRSClientFactoryBean.createWebClient(); restClient.accept(MediaType.APPLICATION_JSON); restClient.type(MediaType.APPLICATION_JSON_TYPE); restClient.header("Authorization", "basic xxxxxxx"); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(30000); httpClientPolicy.setReceiveTimeout(30000); httpClientPolicy.setConnection(ConnectionType.CLOSE); httpClientPolicy.setAllowChunking(false); http.setClient(httpClientPolicy); String responseStr = restClient.get(String.class); System.out.println("Response Received"+responseStr);
当我在Weblogic中执行相同操作时。我得到以下例外。
Caused by: java.io.EOFException: EOFException invoking https://api.testing.net:443/api/v1/Account?AccountId=9: Response contained no data at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1336) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1320) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) ... 147 more Caused by: java.io.EOFException: Response contained no data at weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:227) at weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:148) at weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:468) at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:377) at weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37) at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:965) at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:248) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1515) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1488) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1307)
任何指针。
感谢。