DWR

Tomcat does not shutdown because on non-daemon threads

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Normal Normal
  • Resolution: Fixed
  • Affects Version/s: 3.0.M1, 3.0.RC1
  • Fix Version/s: 3.0.RC2
  • Component/s: Engine
  • Description:
    Hide
    Env: Java 1.6_06, Tomcat 6.0.13, DWR 3.0M1

    After upgrading to DWR3.0M1 tomcat does not shutdown cleanly. The problem was isolated to the DWR servlet by commenting it out from web.xml. After the shutdown was posted to Tomcat the thread dump shows 2 threads created by DWR via executors that are not daemons that prevent JVM from shutting down:


    "pool-2-thread-1" prio=3 tid=0x00934c00 nid=0xd waiting on condition [0x971ef000
    ..0x971efbf0]
       java.lang.Thread.State: TIMED_WAITING (parking)
            at sun.misc.Unsafe.park(Native Method)
            - parking to wait for <0x9c0062c0> (a java.util.concurrent.locks.Abstra
    ctQueuedSynchronizer$ConditionObject)
            at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198
    )
            at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject
    .awaitNanos(AbstractQueuedSynchronizer.java:1963)
            at java.util.concurrent.DelayQueue.take(DelayQueue.java:164)
            at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak
    e(ScheduledThreadPoolExecutor.java:582)
            at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak
    e(ScheduledThreadPoolExecutor.java:575)
            at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.ja
    va:946)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
    .java:906)
            at java.lang.Thread.run(Thread.java:619)

    "pool-1-thread-1" prio=3 tid=0x00586000 nid=0xc waiting on condition [0x9721f000
    ..0x9721fa70]
       java.lang.Thread.State: WAITING (parking)
            at sun.misc.Unsafe.park(Native Method)
            - parking to wait for <0x9c006778> (a java.util.concurrent.locks.Abstra
    ctQueuedSynchronizer$ConditionObject)
            at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
            at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject
    .await(AbstractQueuedSynchronizer.java:1925)
            at java.util.concurrent.DelayQueue.take(DelayQueue.java:160)
            at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak
    e(ScheduledThreadPoolExecutor.java:582)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak
    e(ScheduledThreadPoolExecutor.java:575)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.ja
    va:946)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
    .java:906)
    at java.lang.Thread.run(Thread.java:619)


    Show
    Env: Java 1.6_06, Tomcat 6.0.13, DWR 3.0M1 After upgrading to DWR3.0M1 tomcat does not shutdown cleanly. The problem was isolated to the DWR servlet by commenting it out from web.xml. After the shutdown was posted to Tomcat the thread dump shows 2 threads created by DWR via executors that are not daemons that prevent JVM from shutting down: "pool-2-thread-1" prio=3 tid=0x00934c00 nid=0xd waiting on condition [0x971ef000 ..0x971efbf0]    java.lang.Thread.State: TIMED_WAITING (parking)         at sun.misc.Unsafe.park(Native Method)         - parking to wait for <0x9c0062c0> (a java.util.concurrent.locks.Abstra ctQueuedSynchronizer$ConditionObject)         at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198 )         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject .awaitNanos(AbstractQueuedSynchronizer.java:1963)         at java.util.concurrent.DelayQueue.take(DelayQueue.java:164)         at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak e(ScheduledThreadPoolExecutor.java:582)         at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak e(ScheduledThreadPoolExecutor.java:575)         at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.ja va:946)         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:906)         at java.lang.Thread.run(Thread.java:619) "pool-1-thread-1" prio=3 tid=0x00586000 nid=0xc waiting on condition [0x9721f000 ..0x9721fa70]    java.lang.Thread.State: WAITING (parking)         at sun.misc.Unsafe.park(Native Method)         - parking to wait for <0x9c006778> (a java.util.concurrent.locks.Abstra ctQueuedSynchronizer$ConditionObject)         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)         at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject .await(AbstractQueuedSynchronizer.java:1925)         at java.util.concurrent.DelayQueue.take(DelayQueue.java:160)         at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak e(ScheduledThreadPoolExecutor.java:582) at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.tak e(ScheduledThreadPoolExecutor.java:575) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.ja va:946) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor .java:906) at java.lang.Thread.run(Thread.java:619)
  1. tomcat.patch
    (2 kB)
    Jose Noheda
    10/Jan/09 11:44 AM

Issue Links

Activity

Hide
Jim Steinberger added a comment - 21/Oct/08 8:47 PM

Just wanted to add that this issue is also in the Dev 111 release – I tested with a minimal application, with the web.xml only containing:

<listener>
<listener-class>org.directwebremoting.servlet.DwrListener</listener-class>
</listener>

<servlet>
<display-name>DWR Servlet</display-name>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

If I start up and immediately shut down, everything's fine, but if I access a page with DWR on it, causing the DWR servlet to get loaded, then Tomcat 6.0.16 won't shut down for me and I have to kill it. Note I'm using the org.directwebremoting.servlet.DwrListener.

Show
Jim Steinberger added a comment - 21/Oct/08 8:47 PM Just wanted to add that this issue is also in the Dev 111 release – I tested with a minimal application, with the web.xml only containing: <listener> <listener-class>org.directwebremoting.servlet.DwrListener</listener-class> </listener> <servlet> <display-name>DWR Servlet</display-name> <servlet-name>dwr-invoker</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr-invoker</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> If I start up and immediately shut down, everything's fine, but if I access a page with DWR on it, causing the DWR servlet to get loaded, then Tomcat 6.0.16 won't shut down for me and I have to kill it. Note I'm using the org.directwebremoting.servlet.DwrListener.
Hide
Jose Noheda added a comment - 10/Jan/09 11:43 AM

Spring does not shutdown correctly yet

Show
Jose Noheda added a comment - 10/Jan/09 11:43 AM Spring does not shutdown correctly yet
Hide
Jose Noheda added a comment - 10/Jan/09 11:44 AM

Proposed patch (joins both destroy methods so it must be studied)

Show
Jose Noheda added a comment - 10/Jan/09 11:44 AM Proposed patch (joins both destroy methods so it must be studied)
Hide
Deno Vichas added a comment - 22/Apr/09 11:14 PM

i don't think patching tomcat is the correct answer and to use daemon thread is. see - http://bugs.directwebremoting.org/bugs/browse/DWR-229

Show
Deno Vichas added a comment - 22/Apr/09 11:14 PM i don't think patching tomcat is the correct answer and to use daemon thread is. see - http://bugs.directwebremoting.org/bugs/browse/DWR-229
Hide
Mike Wilson added a comment - 23/Apr/09 9:21 PM

Deno, Jose's patch is an update to DWR source code, not a patch to the Tomcat server.
Your suggestion with daemon threads sounds good but it needs to be tested out carefully so we don't mess up some parts of the shutdown process that we do want to perform.

Show
Mike Wilson added a comment - 23/Apr/09 9:21 PM Deno, Jose's patch is an update to DWR source code, not a patch to the Tomcat server. Your suggestion with daemon threads sounds good but it needs to be tested out carefully so we don't mess up some parts of the shutdown process that we do want to perform.
Hide
David Marginian added a comment - 28/Apr/09 2:21 AM

I have implemented the daemon thread factory and removed all existing shutdown code (previously used to kill threads). Ready for testing.

Show
David Marginian added a comment - 28/Apr/09 2:21 AM I have implemented the daemon thread factory and removed all existing shutdown code (previously used to kill threads). Ready for testing.

People

Dates

  • Created:
    07/Aug/08 8:08 PM
    Updated:
    11/Oct/09 12:38 AM
    Resolved:
    28/Apr/09 2:21 AM