You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ch...@emc.com on 2012/06/04 23:29:51 UTC

daemon thread causing tomcat process to live on

I've got a daemon thread that seems to run after the tomcat has received the shutdown signal.  It's a TimerTask and it appears to fire again after the webapp itself has been shutdown.  This then seems to cause the whole jvm to live on, sometimes for a couple of minutes, sometimes much longer.

The timertask blows up with classnotfounds because the webapp classloader is gone.  Shouldn't it be killed when the webapp is killed?

How do I troubleshoot this?

Re: daemon thread causing tomcat process to live on

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chad,

On 6/5/12 9:58 AM, Chad.Davis@emc.com wrote:
> 
>> 
>> On 6/4/12 5:29 PM, Chad.Davis@emc.com wrote:
>>> I've got a daemon thread that seems to run after the tomcat
>>> has received the shutdown signal.  It's a TimerTask and it
>>> appears to fire again after the webapp itself has been
>>> shutdown.  This then seems to cause the whole jvm to live on,
>>> sometimes for a couple of minutes, sometimes much longer.
>>> 
>>> The timertask blows up with classnotfounds because the webapp 
>>> classloader is gone.  Shouldn't it be killed when the webapp
>>> is killed?
>> 
>> Tomcat won't stop threads created by your webapp: that's up to
>> you.
> 
> Even a daemon thread?  I thought a daemon thread wouldn't stop a
> jvm from exiting . . .

Sorry, I was thinking you were shutting-down your webapp
(stop/undeploy) not the entire Tomcat. Your original post was quite
clear... I just glossed-over it.

Can you capture a thread dump when the JVM is in that state and post
it to the list? Also, if you could post as much of the code of the
task that the TimerTask is actually running, it might help.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/OEsYACgkQ9CaO5/Lv0PD2iQCfaQ6JcN7ScEVrXITqQ7WbHEon
NgoAn1K+YU7xMRUwYnp7qdcHLXy3vznl
=THSE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: daemon thread causing tomcat process to live on

Posted by Ch...@emc.com.
> 
> On 6/4/12 5:29 PM, Chad.Davis@emc.com wrote:
> > I've got a daemon thread that seems to run after the tomcat has
> > received the shutdown signal.  It's a TimerTask and it appears to fire
> > again after the webapp itself has been shutdown.  This then seems to
> > cause the whole jvm to live on, sometimes for a couple of minutes,
> > sometimes much longer.
> >
> > The timertask blows up with classnotfounds because the webapp
> > classloader is gone.  Shouldn't it be killed when the webapp is
> > killed?
> 
> Tomcat won't stop threads created by your webapp: that's up to you.

Even a daemon thread?  I thought a daemon thread wouldn't stop a jvm from exiting . . . 
 



Re: daemon thread causing tomcat process to live on

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chad,

On 6/4/12 5:29 PM, Chad.Davis@emc.com wrote:
> I've got a daemon thread that seems to run after the tomcat has 
> received the shutdown signal.  It's a TimerTask and it appears to 
> fire again after the webapp itself has been shutdown.  This then 
> seems to cause the whole jvm to live on, sometimes for a couple of 
> minutes, sometimes much longer.
> 
> The timertask blows up with classnotfounds because the webapp 
> classloader is gone.  Shouldn't it be killed when the webapp is 
> killed?

Tomcat won't stop threads created by your webapp: that's up to you.

> How do I troubleshoot this?

First, you'll have to find out where the thread is being created.
Ideally, it will be created in a ServletContextListener's or a
Servlet's init method. Just add appropriate code to the destroy()
method so shut-down the thread. Depending on what the thread does, you
may need to modify the task being executed so that it can be
gracefully cancelled when your webapp stops.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/NLEMACgkQ9CaO5/Lv0PBacACeO4G06QzQI3sQBDImfr7BCfgE
47oAnRNDC+wtCEST1iCaYIk6XRaPTSPl
=GDOO
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org