You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jørgen Nørgaard <jn...@anneli.dk> on 2006/10/18 10:02:15 UTC

Re: After stopping tomcat, the tomcat process still appears to be running

Hello,


If your servlet(s) start new threads that run independently of request
this may happen.

Could this be the case?

On Wed, October 18, 2006 01:42, Elaine TING wrote:
> Hi,
>
> This is what I have done:
>
> 1) use shutdown.sh to shut down tomcat
> 2) Now the website appears to be down
> 3) Use ps -ef | grep tomcat to check the processes, tomcat still appears
> to be running:
>> ps -ef | grep tomcat
> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> 4) use startup.sh to start tomcat
> 5) website appears to be up and running again
> 6) check the processes, now there are 2 tomcats running:
>
>> ps -ef | grep tomcat
> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> root     22108     1  1 14:33 pts/21   00:00:19 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> ops      22427 10618  0 14:52 pts/21   00:00:00 grep tomcat
>
> Why was shutdown.sh unable to kill the tomcat process? I'm running
> Tomcat 5.0.28 on SUSE LINUX Enterprise Server 9. Java version: 1.5.0_03.
>
> Thank you in advance,
> Elaine
>
>


-- 
/jørgen nørgaard
e-mail: jnp@anneli.dk | Phone: +45 2627 3769
http://anneli.dk/~jnp/
                                         |\      _,,,---,,_
                                         /,`.-'`'    -.  ;-;;,_
                                         |,4-  ) )-,_. ,\ (  `'-'
                                        '---''(_/--'  `-'\_)



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


RE: After stopping tomcat, the tomcat process still appearsto be running

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: David Smith [mailto:dns4@cornell.edu] 
> Subject: Re: After stopping tomcat, the tomcat process still 
> appearsto be running
> 
> To the best of my knowlege, System.exit() is never called from within 
> tomcat.

Well ... that's not quite true.  There are several calls to
System.exit() in the Tomcat source, but the only ones that appear to be
possibilities are ones dealing with exceptions while waiting on the
shutdown port.  Look at the org.apache.catalina.core.StandardServer
code.  There are also a few that can occur during initialization or
termination if errors are detected (e.g.,
org.apache.catalina.startup.Catalina).

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


Re: After stopping tomcat, the tomcat process still appears to be running

Posted by David Smith <dn...@cornell.edu>.
To the best of my knowlege, System.exit() is never called from within 
tomcat.  Tomcat closes it's own daemon threads and then exits normally 
like any other java program.  If a third party package starts it's own 
thread, that package is responsible for cleaning up what it starts.  
Tomcat won't exit until the threads are properly cleaned up.

--David

Tomas Hulek wrote:

>AFAIK Tomcat does not call System.exit() - at least did not in version
>4.1.*, when we solved the very same problem.
>
>T.
>
>
>
>                                                                           
>             Christopher                                                   
>             Schultz                                                       
>             <chris@christophe                                          To 
>             rschultz.net>             Tomcat Users List                   
>                                       <us...@tomcat.apache.org>           
>             18.10.2006 14:36                                           cc 
>                                                                           
>                                                                   Subject 
>             Please respond to         Re: After stopping tomcat,      the 
>               "Tomcat Users           tomcat process still appears to be  
>                   List"               running                             
>             <users@tomcat.apa                                             
>                 che.org>                                                  
>                                                                           
>                                                                           
>                                                                           
>                                                                           
>
>
>
>
>Tomas,
>
>  
>
>>At JVM shutdown, the JVM is terminated only if all remaining running
>>threads are daemon threads.
>>    
>>
>
>Not true. System.exit() kills the VM regardless of the presence of
>non-daemon threads.
>
>-chris
>
>
>(See attached file: signature.asc)
>  
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: After stopping tomcat, the tomcat process still appears to be running

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Tomas,

To be fair, you did say JVM shutdown, not Tomcat shutdown.

> AFAIK Tomcat does not call System.exit() - at least did not in version
> 4.1.*, when we solved the very same problem.

Here:

>> At JVM shutdown, the JVM is terminated only if all remaining running
>> threads are daemon threads.
> 
> Not true. System.exit() kills the VM regardless of the presence of
> non-daemon threads.



Re: After stopping tomcat, the tomcat process still appears to be running

Posted by Tomas Hulek <th...@cz.ibm.com>.
AFAIK Tomcat does not call System.exit() - at least did not in version
4.1.*, when we solved the very same problem.

T.



                                                                           
             Christopher                                                   
             Schultz                                                       
             <chris@christophe                                          To 
             rschultz.net>             Tomcat Users List                   
                                       <us...@tomcat.apache.org>           
             18.10.2006 14:36                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Re: After stopping tomcat,      the 
               "Tomcat Users           tomcat process still appears to be  
                   List"               running                             
             <users@tomcat.apa                                             
                 che.org>                                                  
                                                                           
                                                                           
                                                                           
                                                                           




Tomas,

> At JVM shutdown, the JVM is terminated only if all remaining running
> threads are daemon threads.

Not true. System.exit() kills the VM regardless of the presence of
non-daemon threads.

-chris


(See attached file: signature.asc)

Re: After stopping tomcat, the tomcat process still appears to be running

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Tomas,

> At JVM shutdown, the JVM is terminated only if all remaining running
> threads are daemon threads.

Not true. System.exit() kills the VM regardless of the presence of
non-daemon threads.

-chris



Re: After stopping tomcat, the tomcat process still appears to be running

Posted by Jon Wingfield <jo...@mkodo.com>.
You've also got other candidates such as database connections, JMS 
connections etc which could spawn threads (For example, for keep-alive 
functionality).

The easiest thing to do is a thread dump (send the process a SIGQUIT 
signal) after stopping tomcat to see which thread(s) are keeping the JVM 
up. Once identified you need to fix your code.

HTH,

Jon

Tomas Hulek wrote:
> At JVM shutdown, the JVM is terminated only if all remaining running
> threads are daemon threads.
> 
> Therefore, if the application starts own threads, it is necessary to ensure
> that
> 
> 1) either all these threads are destroyed before JVM shutdown by calling
> the stop() method for each of the threads,
> 
> 2) or make them daemon threads by calling setDaemon() right after thread
> creation.
> 
> 
> Tomas
> 
> 
>                                                                            
>              Jørgen Nørgaard                                               
>              <jn...@anneli.dk>                                               
>                                                                         To 
>              18.10.2006 10:02          "Tomcat Users List"                 
>                                        <us...@tomcat.apache.org>           
>                                                                         cc 
>              Please respond to                                             
>                "Tomcat Users                                       Subject 
>                    List"               Re: After stopping tomcat,      the 
>              <users@tomcat.apa         tomcat process still appears to be  
>                  che.org>              running                             
>                                                                            
>                                                                            
>                                                                            
>                                                                            
>                                                                            
>                                                                            
> 
> 
> 
> 
> Hello,
> 
> 
> If your servlet(s) start new threads that run independently of request
> this may happen.
> 
> Could this be the case?
> 
> On Wed, October 18, 2006 01:42, Elaine TING wrote:
>> Hi,
>>
>> This is what I have done:
>>
>> 1) use shutdown.sh to shut down tomcat
>> 2) Now the website appears to be down
>> 3) Use ps -ef | grep tomcat to check the processes, tomcat still appears
>> to be running:
>>> ps -ef | grep tomcat
>> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
>> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
>> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
>> arta-tomcat/bin/commons-logging-api.jar
>> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
>> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
>> org.apache.catalina.startup.Bootstrap start
>> 4) use startup.sh to start tomcat
>> 5) website appears to be up and running again
>> 6) check the processes, now there are 2 tomcats running:
>>
>>> ps -ef | grep tomcat
>> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
>> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
>> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
>> arta-tomcat/bin/commons-logging-api.jar
>> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
>> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
>> org.apache.catalina.startup.Bootstrap start
>> root     22108     1  1 14:33 pts/21   00:00:19 /local/Java/bin/java
>> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
>> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
>> arta-tomcat/bin/commons-logging-api.jar
>> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
>> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
>> org.apache.catalina.startup.Bootstrap start
>> ops      22427 10618  0 14:52 pts/21   00:00:00 grep tomcat
>>
>> Why was shutdown.sh unable to kill the tomcat process? I'm running
>> Tomcat 5.0.28 on SUSE LINUX Enterprise Server 9. Java version: 1.5.0_03.
>>
>> Thank you in advance,
>> Elaine
>>
>>
> 
> 
> --
> /jørgen nørgaard
> e-mail: jnp@anneli.dk | Phone: +45 2627 3769
> http://anneli.dk/~jnp/
>                                          |\      _,,,---,,_
>                                          /,`.-'`'    -.  ;-;;,_
>                                          |,4-  ) )-,_. ,\ (  `'-'
>                                         '---''(_/--'  `-'\_)
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 



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


RE: After stopping tomcat, the tomcat process still appears to berunning

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tomas Hulek [mailto:thulek@cz.ibm.com] 
> Subject: Re: After stopping tomcat, the tomcat process still 
> appears to berunning
> 
> 1) either all these threads are destroyed before JVM shutdown 
> by calling the stop() method for each of the threads,

A really, really bad idea and a sign of amateur programming.  To quote
from the JRE API spec:

"stop()
Deprecated. This method is inherently unsafe. Stopping a thread with
Thread.stop causes it to unlock all of the monitors that it has locked
(as a natural consequence of the unchecked ThreadDeath exception
propagating up the stack). If any of the objects previously protected by
these monitors were in an inconsistent state, the damaged objects become
visible to other threads, potentially resulting in arbitrary behavior.
Many uses of stop should be replaced by code that simply modifies some
variable to indicate that the target thread should stop running. The
target thread should check this variable regularly, and return from its
run method in an orderly fashion if the variable indicates that it is to
stop running. If the target thread waits for long periods (on a
condition variable, for example), the interrupt method should be used to
interrupt the wait. For more information, see Why are Thread.stop,
Thread.suspend and Thread.resume Deprecated?"
http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecatio
n.html

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

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


Re: After stopping tomcat, the tomcat process still appears to be running

Posted by Tomas Hulek <th...@cz.ibm.com>.
At JVM shutdown, the JVM is terminated only if all remaining running
threads are daemon threads.

Therefore, if the application starts own threads, it is necessary to ensure
that

1) either all these threads are destroyed before JVM shutdown by calling
the stop() method for each of the threads,

2) or make them daemon threads by calling setDaemon() right after thread
creation.


Tomas


                                                                           
             Jørgen Nørgaard                                               
             <jn...@anneli.dk>                                               
                                                                        To 
             18.10.2006 10:02          "Tomcat Users List"                 
                                       <us...@tomcat.apache.org>           
                                                                        cc 
             Please respond to                                             
               "Tomcat Users                                       Subject 
                   List"               Re: After stopping tomcat,      the 
             <users@tomcat.apa         tomcat process still appears to be  
                 che.org>              running                             
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hello,


If your servlet(s) start new threads that run independently of request
this may happen.

Could this be the case?

On Wed, October 18, 2006 01:42, Elaine TING wrote:
> Hi,
>
> This is what I have done:
>
> 1) use shutdown.sh to shut down tomcat
> 2) Now the website appears to be down
> 3) Use ps -ef | grep tomcat to check the processes, tomcat still appears
> to be running:
>> ps -ef | grep tomcat
> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> 4) use startup.sh to start tomcat
> 5) website appears to be up and running again
> 6) check the processes, now there are 2 tomcats running:
>
>> ps -ef | grep tomcat
> root     21892     1  1 14:30 pts/21   00:00:17 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> root     22108     1  1 14:33 pts/21   00:00:19 /local/Java/bin/java
> -Djava.endorsed.dirs=/opt/jakarta-tomcat/common/endorsed -classpath
> /local/Java/lib/tools.jar:/opt/jakarta-tomcat/bin/bootstrap.jar:/opt/jak
> arta-tomcat/bin/commons-logging-api.jar
> -Dcatalina.base=/opt/jakarta-tomcat -Dcatalina.home=/opt/jakarta-tomcat
> -Djava.io.tmpdir=/opt/jakarta-tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> ops      22427 10618  0 14:52 pts/21   00:00:00 grep tomcat
>
> Why was shutdown.sh unable to kill the tomcat process? I'm running
> Tomcat 5.0.28 on SUSE LINUX Enterprise Server 9. Java version: 1.5.0_03.
>
> Thank you in advance,
> Elaine
>
>


--
/jørgen nørgaard
e-mail: jnp@anneli.dk | Phone: +45 2627 3769
http://anneli.dk/~jnp/
                                         |\      _,,,---,,_
                                         /,`.-'`'    -.  ;-;;,_
                                         |,4-  ) )-,_. ,\ (  `'-'
                                        '---''(_/--'  `-'\_)



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




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