GeeCON Prague 2014*
The moose likes Tomcat and the fly likes Tomcat hanging on shutdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat hanging on shutdown" Watch "Tomcat hanging on shutdown" New topic
Author

Tomcat hanging on shutdown

David Heinecke
Greenhorn

Joined: Mar 30, 2011
Posts: 3
Hi,

I am having an intermittent issue with trying to stop Tomcat 5.5.29 on Windows when running as a service. Most times, when I stop tomcat with the service control manager, it stops just fine, but about 1 in 3 times, when I try to shut it down this way, it hangs on shutdown and must be physically killed. This never happens when tomcat is run as a console application, so it makes me wonder if the problem is with the service wrapper or with tomcat proper.

Here is a jstack listing of the hung tomcat.

2011-03-29 12:24:15
Full thread dump Java HotSpot(TM) Server VM (16.0-b13 mixed mode):

"AWT-Windows" daemon prio=6 tid=0x2da0f000 nid=0x4384 runnable [0x35bbf000]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(WToolkit.java:295)
at java.lang.Thread.run(Thread.java:619)

"Java2D Disposer" daemon prio=10 tid=0x2da0e400 nid=0x4350 in Object.wait() [0x359af000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0fbc6278> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
- locked <0x0fbc6278> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
at sun.java2d.Disposer.run(Disposer.java:125)
at java.lang.Thread.run(Thread.java:619)

"http-315-Processor24" daemon prio=6 tid=0x2d83c400 nid=0x2474 waiting on condition [0x312ff000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:62)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)

"http-314-Processor20" daemon prio=6 tid=0x2dc91000 nid=0x50c waiting on condition [0x3021f000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:62)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)

"Timer-0" daemon prio=6 tid=0x2da0a800 nid=0x23a0 in Object.wait() [0x2f64f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0ceb50e8> (a java.util.TaskQueue)
at java.lang.Object.wait(Object.java:485)
at java.util.TimerThread.mainLoop(Timer.java:483)
- locked <0x0ceb50e8> (a java.util.TaskQueue)
at java.util.TimerThread.run(Timer.java:462)

"Thread-2" daemon prio=6 tid=0x2e5d0000 nid=0x1a10 waiting on condition [0x2e22f000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.apache.log4j.helpers.FileWatchdog.run(FileWatchdog.java:103)

"Low Memory Detector" daemon prio=6 tid=0x2cdf7800 nid=0x1648 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x2cdf4400 nid=0x1644 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x2cdef800 nid=0x1640 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x2cdef000 nid=0x163c waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x00d8f800 nid=0x1638 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x2cdc7800 nid=0x140c in Object.wait() [0x2d08f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0ce94d48> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
- locked <0x0ce94d48> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x2cdc1c00 nid=0x1408 in Object.wait() [0x2cfff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0ce94d00> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x0ce94d00> (a java.lang.ref.Reference$Lock)

"main" prio=6 tid=0x00e19400 nid=0x13a8 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE

"VM Thread" prio=10 tid=0x2cdc0400 nid=0x1404 runnable

"GC task thread#0 (ParallelGC)" prio=6 tid=0x00cffc00 nid=0xc48 runnable

"GC task thread#1 (ParallelGC)" prio=6 tid=0x00d01000 nid=0x1154 runnable

"GC task thread#2 (ParallelGC)" prio=6 tid=0x00d02000 nid=0x1168 runnable

"GC task thread#3 (ParallelGC)" prio=6 tid=0x00d03400 nid=0x12e0 runnable

"GC task thread#4 (ParallelGC)" prio=6 tid=0x00d06400 nid=0x12d0 runnable

"GC task thread#5 (ParallelGC)" prio=6 tid=0x00d07400 nid=0x12e8 runnable

"GC task thread#6 (ParallelGC)" prio=6 tid=0x00d08000 nid=0x12f4 runnable

"GC task thread#7 (ParallelGC)" prio=6 tid=0x00d08c00 nid=0x12f0 runnable

"GC task thread#8 (ParallelGC)" prio=6 tid=0x00d11800 nid=0x12e4 runnable

"GC task thread#9 (ParallelGC)" prio=6 tid=0x00d14000 nid=0x12dc runnable

"GC task thread#10 (ParallelGC)" prio=6 tid=0x00d14800 nid=0x130c runnable

"GC task thread#11 (ParallelGC)" prio=6 tid=0x00d15c00 nid=0x12cc runnable

"GC task thread#12 (ParallelGC)" prio=6 tid=0x00d16400 nid=0x1360 runnable

"VM Periodic Task Thread" prio=10 tid=0x2cdf8400 nid=0x164c waiting on condition

JNI global references: 1107

Since there is absolutely nothing (as far as my untrained eye is concerned) that is preventing tomcat from exiting, it makes me believe that there is something in the service wrapper that is to blame. Has anyone else ever had this problem, or can provide some guidance where I should be looking for the problem?

TIA!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21


"VM Periodic Task Thread" prio=10 tid=0x2cdf8400 nid=0x164c waiting on condition


See if you can drill into this thread. Tomcat cannot shut down until ALL of its threads have terminated, so if one of them is waiting for something, you need to find out what it wants and how to make it happy.


Customer surveys are for companies who didn't pay proper attention to begin with.
David Heinecke
Greenhorn

Joined: Mar 30, 2011
Posts: 3
According to this Stack Overflow Q & A, the VM Periodic task is not a Tomcat thread, but a VM thread that is primarily used for timing events for systems that don't have native timer interrupt support.

http://stackoverflow.com/questions/5258948/what-is-the-vm-periodic-task-thread

Based just on that, this thread shouldn't be stopping Tomcat from exiting.

The only thing that jumps out to me with this trace are the hosts of non-daemon GC threads. These, also, are not tomcat threads but the VM threads, so I still can't really fathom why tomcat wouldn't exit.

I'm becoming more and more convinced that the problem is in the commons-daemon service wrapper that we use to launch tomcat as a service.


 
jQuery in Action, 2nd edition
 
subject: Tomcat hanging on shutdown