2 Replies Latest reply on Jan 29, 2011 3:22 AM by Michal Kára

    HornetQ fails to stop threads in Tomcat

    Michal Kára Newbie

      I have a problem which seems to be trivial, but I cannot found what I am doing wrong. I do in a web application in Tomcat:

       

      ClientSessionFactory factory = HornetQClient.createClientSessionFactory(hornetQTransportConfig);

      ClientSession session = factory.createSession();

      try { if (session != null) session.close(); } catch(Exception e) {}

      try { if (factory != null) factory.close(); } catch(Exception e) {}

       

      This is "well behaved" application as described in http://hornetq.sourceforge.net/docs/hornetq-2.0.0.BETA5/user-manual/en/html/connection-ttl.html

      ando should start and cleanup HornetQ client. But when I undeploy application, Tomcat complains:

       

      28.1.2011 20:59:58 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: A web application appears to have started a thread named [Thread-0 (group:HornetQ-client-global-threads-8433528)] but has failed to stop it. This is very likely to create a memory leak.

      28.1.2011 20:59:58 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

      SEVERE: A web application appears to have started a thread named [Thread-0 (group:HornetQ-client-global-scheduled-threads-12263675)] but has failed to stop it. This is very likely to create a memory leak.

       

      and it is right. This causes problems when the application is redeployed.

       

      HornetQ version is 2.1.2.Final

       

      Here is excerpt from thread dump after hornetq is cleaned up:

       

      "Thread-1 (group:HornetQ-client-global-threads-31423635)" daemon prio=6 tid=0x0c982000 nid=0x166c waiting on condition [0x0eebf000..0x0eebf9e8]

         java.lang.Thread.State: TIMED_WAITING (parking)

          at sun.misc.Unsafe.park(Native Method)

          - parking to wait for  <0x0500db98> (a java.util.concurrent.SynchronousQueue$TransferStack)

          at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)

          at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)

          at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)

          at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)

          at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:944)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)

          at java.lang.Thread.run(Thread.java:619)

       

      "Thread-0 (group:HornetQ-client-global-scheduled-threads-22043518)" daemon prio=6 tid=0x0c981800 nid=0x1204 waiting on condition [0x0ee6f000..0x0ee6fa68]

         java.lang.Thread.State: WAITING (parking)

          at sun.misc.Unsafe.park(Native Method)

          - parking to wait for  <0x05011268> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$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.take(ScheduledThreadPoolExecutor.java:582)

          at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:575)

          at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:946)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)

          at java.lang.Thread.run(Thread.java:619)

       

      "Thread-0 (group:HornetQ-client-global-threads-31423635)" daemon prio=6 tid=0x0c97f800 nid=0xec4 waiting on condition [0x0ee1f000..0x0ee1fae8]

         java.lang.Thread.State: TIMED_WAITING (parking)

          at sun.misc.Unsafe.park(Native Method)

          - parking to wait for  <0x0500db98> (a java.util.concurrent.SynchronousQueue$TransferStack)

          at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)

          at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424)

          at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323)

          at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874)

          at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:944)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:906)

          at java.lang.Thread.run(Thread.java:619)

       

       

      How can I make the threads stopped?

       

      Thanks,

      Michal