Oracle Linux: 2.6.18-274.el5 x86_64, tomcat 7.0.68
We are in the process of upgrading an axis2 application from java 6 to java 8 and have been running tests against existing jax-ws axis2 services.
We have a web service, running on tomcat, that is placing a client call, also via jax-ws to an external web service via an SSL connection.
After switching from java 6 to java 8 we have found that the client call is still working.
However, when placing a second call to the same web service the call fails with a "java.net.SocketException: Socket Closed" exception.
This issue is occurring consistently, i.e. if we restart the tomcat server and then execute the web service which places the client call, via SoapUI, the same exception is logged.
On further analysis of the log file it seems that, on the second call, the http connection is being returned from the cache via the httpclient MultiThreadedHttpConnectionManager class.
The exception is logged, as below:
DEBUG org.apache.commons.httpclient.HttpConnection - An error occurred while reading from the socket, is appears to be stale
java.net.SocketException: Socket Closed
It therefore seems that the remote server, to which we are placing the client jax-ws call, is closing the connection immediately after sending the response but that the client is not detecting this.
When the next web service call is placed via the client the connection is retrieved from the connection pool, the httpclient.HttpConnection.isStale() check is performed, the connection is not correctly detected as being stale and then the ssl.SSLSocketImpl.setSoTimeout() method is called to reset the socket timeout, java net then detects that the connection is no longer active and raises the socket exception.
Note that when this issue occurs it is no longer possible to run this web service, i.e. the socket exception is then output on every invocation of the service until the tomcat server is restarted.
Also, note that this issue only occurs with java 8. The socket exception is not output with java 6.
I have performed tests with different versions of axis2 and found that, with version 1.6.0, the same socket exception is output but that a new connection is then opened and the web service then executes and returns a response without issue.
Finally, I read the Apache Axis2 1.7.0 release note which states that Axis2 1.7.0 and above supports Apache HttpClient 4.x in addition to the no longer maintained Commons HttpClient 3.x.
I have attempted to follow the instructions for upgrading the HttpClient to release 4.x but in the log file I'm still seeing output for org.apache.commons.httpclient.HttpConnection.
It seems that the change applied to the axis2.xml config file is not taking effect.
Please could you help with the resolution for the socket exception issue and also give guidance with upgrading the HttpClient to version 4.2.5.