views:

478

answers:

2

After shutting down tomcat, I get this message:

INFO: Failed shutdown of Apache Portable Runtime

Then Tomcat shuts down after all

I haven't found a reasonable explanation googling around, nor in the single duplicate I've found (0 answers)

+1  A: 

The most common cause is that a non-daemon thread is still running (Tomcat FAQ). Click here for more information on daemon threads.

To find out which thread is causing problems (on Unix):

  • do a kill -3 tomcatProcId (find tomcatProcId using ps)
  • look inside $TOMCAT_HOME/logs/catalina.out for the thread dump generated by the kill
  • look at all the non-daemon threads (those not marked with "daemon") that are not VM/GC related
  • for each one, find out what code spawned it, and why it has not terminated correctly. Some non-daemon threads check frequently to terminate, which is OK.

If you want, you can instruct Tomcat to kill the JVM after shutdown, even if non-daemon threads remain (which might sometimes be a bad thing):

  • define the CATALINA_PID environment variable. For example: export CATALINA_PID=/tmp/catalina_pid
  • use catalina.sh stop -force to stop Tomcat.
eneveu
+1 on a good and thorough answer, but I'm not sure it is the deal, please read my answer as well, and comment if you don't think it resolves my own question
Ehrann Mehdan
Good point. I missed the "Then Tomcat shuts down after all" part. Your answer seems to be the correct one in this case, and you should accept it. I hope my answer will still help other people, who might encounter the Daemon Thread problem.
eneveu
+1  A: 

It seems that this is not due to some daemon threads after all, just a poor log message

https://issues.apache.org/bugzilla/show_bug.cgi?id=38652

Ehrann Mehdan