Hi,
I'm happily using Spring-WS 2.0.2 along with Commons HttpClient 3.0.1 on Apache Tomcat 6.0.33. However, Tomcat's memory leak prevention and detection feature logs the following when my application is stopped:
The MultiThreadedHttpConnectionManager is instantiated by CommonsHttpMessageSender (in the no-args constructor), which also calls MultiThreadedHttpConnectionManager.shutdown() in destroy():Code:SEVERE: The web application [/example] appears to have started a thread named [MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is very likely to create a memory leak.
According to the docs, MultiThreadedHttpConnectionManager.shutdown() "shuts down the connection manager and releases all resources". So something doesn't seem to work the way it should.Code:public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSender implements InitializingBean, DisposableBean { ... // as defined in DisposableBean public void destroy() throws Exception { HttpConnectionManager connectionManager = getHttpClient().getHttpConnectionManager(); if (connectionManager instanceof MultiThreadedHttpConnectionManager) { ((MultiThreadedHttpConnectionManager) connectionManager).shutdown(); } } ... }
Could it be that CommonsHttpMessageSender.destroy() doesn't get called by the bean factory? Maybe due to the way my bean definitions are set up (using anonymous inner beans and bean definition inheritance)?
Code:<bean id="myGateway" class="com.example.MyGateway"> <property name="webServiceTemplate"> <bean parent="abstractWebServiceTemplate"> <property name="marshaller">...</property> <property name="unmarshaller">...</property> </bean> </property> </bean> ... <bean id="abstractWebServiceTemplate" abstract="true" class="org.springframework.ws.client.core.WebServiceTemplate"> <property name="messageSender"> <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender"> <property name="connectionTimeout" value="20"/> <property name="readTimeout" value="20"/> </bean> </property> </bean>
On the other hand, I'm irritated by the word "cleanup" in the thead's name "MultiThreadedHttpConnectionManager cleanup". Is MultiThreadedHttpConnectionManager already performing its cleanup? But then why doesn't it finish before Tomcat complains?
Thanks for your input!
Cheers, Dan.


Reply With Quote
