struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom K <>
Subject Re: Help with problem: ThreadLocal left after stopping tomcat
Date Wed, 07 Mar 2012 14:17:55 GMT
Thanks for the reply.

Based on my experimentation it appears these threads are started by the
Struts framework on startup. As I mentioned if I comment out my 
StrutsPrepareAndExecute filter
and start/stop the app, I don't get any SEVERE warnings from tomcat.

I can catch the Web Application shutdown by implementing a ContextLoaderListener 
and perform
cleanup by overriding the contextDestroyed() method. However in my searching and 
reading so far
I haven't found a solid clue as to what classes or beans struts uses I might 
explicitly try and get
to and force cleanup on. 

Does anyone have any ideas?


----- Original Message ----
From: Greg Lindholm <>
To: Struts Users Mailing List <>
Sent: Wed, March 7, 2012 7:56:53 AM
Subject: Re: Help with problem: ThreadLocal left after stopping tomcat

I also get a boat-load of these ThreadLocal errors when I stop my app
(using Tomcat 6).  Tomcat 6 & 7 are now checking and reporting on all the
debris that gets left behind when an app shuts down.

I don't think the WW-560 addresses this problem.

If I understand it correctly the problem is when the app shuts down it is
failing to cleanup some ThreadLocal variables. To fix this issue something
would need to keep track of these variables and remove them when the app
terminates. It also means it would need to either be notified about the
shutdown or explicitly called to cleanup during shutdown.  Since these are
ThreadLocal it could be a tricky problem.

On Tue, Mar 6, 2012 at 11:57 AM, Tom K <> wrote:

> Hello,
> When stopping or undeploying my struts 2 web app in Tomcat (7.0.23) I get
> several severe warnings from tomcat:
> SEVERE: The web application [/myapp] created a ThreadLocal with key  of
> type
> [com.opensymphony.xwork2.inject.ContainerImpl$10] (value
> [com.opensymphony.xwork2.inject.ContainerImpl$10@1376afa]) and a value
>  of type
> [java.lang.Object[]] (value [[Ljava.lang.Object;@15075f9]) but  failed to
> remove
> it when the web application was stopped. Threads are  going to be renewed
> over
> time to try and avoid a probable memory leak.
> I've hunted all over the web and found this error repeated in several
>  places,
> but I haven't yet found a solution. I then found some posts  that lead me
> to
> believe this was a problem in the xwork libs but that it  had been
> resolved in
> the latest version:
> I also found a reference suggesting this could be a problem with  using the
> deprecated FilterDispatcher rather than a  StrutsPrepareAndExecuteFilter:
> I was originally using Struts and upgraded to the latest  (
> which didn't solve the problem, nor did switching back and  forth between
> the
> FilterDispatcher and StrutsPrepareAndExecuteFilter  (the following is from
> my
> web.xml):
> <filter>     <filter-name>action2</filter-name>
>  </filter>  <filter-mapping>
> <filter-name>httpResponseFilter</filter-name>
> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping>
> <filter-name>action2</filter-name>     <url-pattern>/*</url-pattern>
> </filter-mapping>
> I also tried an IntrospectorCleanupListener as a shot in the dark but to no
> avail.
> If I comment out the StrutsPrepareAndExecuteFilter and deploy/stop  the
> web app,
> the severe warnings regarding ThreadLocal's go away (though  obviously my
> web
> app no longer works).
> At this point I'm not sure what else to try - is there some  additional
> cleanup
> I can perform via a ContextLoaderListener or  otherwise on struts to shut
> it
> down properly when the web app is  stopped? Or are there still bugs in
> struts
> 2/xwork causing this issue  that  haven't been resolved?
> Any suggestions or help much appreciated.
> Thanks,
> Tom
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message