cancel
Showing results for 
Search instead for 
Did you mean: 

Starting activiti at ServletContext Initialization causes wait forever at Servlet Context destroy

edsonrichter
Confirmed Champ
Confirmed Champ
I've a simple Activiti web app running on Tomcat (either 7.0.68 or 8.0.39).
I cant shutdown it *** on windows *** - and I'm not sure about running in Linux (since Threading is differente in Linux and Windows, I think it is important to alert that this is happening in Windows).

Configuration:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/activiti"/>
  </bean>
  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
  </bean>
</beans>

jdbc resource is configure as:

  <Resource auth="Container" description="Activity"
            driverClassName="org.postgresql.Driver"
            logAbandoned="true" maxActive="5" maxIdle="1"
            maxWait="60000" name="jdbc/activiti"
            username="activiti" password="xyxyxyxyxyxy"
            poolPreparedStatements="true"
            removeAbandoned="true"
            removeAbandonedTimeout="6000" type="javax.sql.DataSource"
            url="jdbc:postgresql://127.0.0.1:5432/thedb"/>

if I start Activiti at Tomcat "Servlet Context" initialization, when I signal to shutdown the server, it destroy all services (including ProcessEngines.destroy) with success, but stay stuck with the following threads:


2016-06-06 14:32:40
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.91-b14 mixed mode):

"DestroyJavaVM" #95 prio=5 os_prio=0 tid=0x000000005da66800 nid=0x3824 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"RMI RenewClean-[192.168.10.30:53033]" #34 daemon prio=5 os_prio=0 tid=0x000000005da62000 nid=0x2f1c in Object.wait() [0x000000006201e000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000b1053f08> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
   - locked <0x00000000b1053f08> (a java.lang.ref.ReferenceQueue$Lock)
   at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:553)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"RMI Reaper" #32 prio=5 os_prio=0 tid=0x000000005da60800 nid=0x30d0 in Object.wait() [0x0000000065f6f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a9e659b0> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
   - locked <0x00000000a9e659b0> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
   at sun.rmi.transport.ObjectTable$Reaper.run(ObjectTable.java:351)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"RMI TCP Accept-0" #31 daemon prio=5 os_prio=0 tid=0x000000005da60000 nid=0x335c runnable [0x0000000065cfe000]
   java.lang.Thread.State: RUNNABLE
   at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
   at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
   at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
   - locked <0x00000000b1004ca0> (a java.net.SocksSocketImpl)
   at java.net.ServerSocket.implAccept(ServerSocket.java:545)
   at java.net.ServerSocket.accept(ServerSocket.java:513)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:400)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:372)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"RMI TCP Accept-1099" #29 daemon prio=5 os_prio=0 tid=0x000000005da5e800 nid=0x1d20 runnable [0x0000000062a0f000]
   java.lang.Thread.State: RUNNABLE
   at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
   at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
   at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
   - locked <0x00000000b10503e0> (a java.net.SocksSocketImpl)
   at java.net.ServerSocket.implAccept(ServerSocket.java:545)
   at java.net.ServerSocket.accept(ServerSocket.java:513)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:400)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:372)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"commons-pool-EvictionTimer" #25 daemon prio=5 os_prio=0 tid=0x000000005da5b800 nid=0x38d4 in Object.wait() [0x000000005c7ce000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   at java.util.TimerThread.mainLoop(Timer.java:552)
   - locked <0x00000000abe89f50> (a java.util.TaskQueue)
   at java.util.TimerThread.run(Timer.java:505)

   Locked ownable synchronizers:
   - None

"RMI TCP Connection(2)-192.168.10.30" #24 daemon prio=5 os_prio=0 tid=0x000000005da5a800 nid=0x3864 runnable [0x0000000062b2d000]
   java.lang.Thread.State: RUNNABLE
   at java.net.SocketInputStream.socketRead0(Native Method)
   at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
   at java.net.SocketInputStream.read(SocketInputStream.java:170)
   at java.net.SocketInputStream.read(SocketInputStream.java:141)
   at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
   at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
   - locked <0x00000000ad1bd8c8> (a java.io.BufferedInputStream)
   at java.io.FilterInputStream.read(FilterInputStream.java:83)
   at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:550)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$4/811861329.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - <0x00000000ad8e5700> (a java.util.concurrent.ThreadPoolExecutor$Worker)

"JMX server connection timeout 23" #23 daemon prio=5 os_prio=0 tid=0x000000005f494000 nid=0x3478 in Object.wait() [0x000000006238e000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   at com.sun.jmx.remote.internal.ServerCommunicatorAdmin$Timeout.run(ServerCommunicatorAdmin.java:168)
   - locked <0x00000000aeccbbf0> (a [I)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"RMI Scheduler(0)" #22 daemon prio=5 os_prio=0 tid=0x000000005c369000 nid=0x1bb0 waiting on condition [0x0000000061ede000]
   java.lang.Thread.State: TIMED_WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x00000000a9a05930> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
   at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
   at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"RMI TCP Accept-0" #20 daemon prio=5 os_prio=0 tid=0x000000005f27e000 nid=0x1e2c runnable [0x00000000624ff000]
   java.lang.Thread.State: RUNNABLE
   at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
   at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
   at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
   - locked <0x00000000aecb4320> (a java.net.SocksSocketImpl)
   at java.net.ServerSocket.implAccept(ServerSocket.java:545)
   at java.net.ServerSocket.accept(ServerSocket.java:513)
   at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:52)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:400)
   at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:372)
   at java.lang.Thread.run(Thread.java:745)

   Locked ownable synchronizers:
   - None

"GC Daemon" #15 daemon prio=2 os_prio=-2 tid=0x000000005abf3800 nid=0x250c in Object.wait() [0x000000005b47e000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   - waiting on <0x00000000a9a245e8> (a sun.misc.GC$LatencyLock)
   at sun.misc.GC$Daemon.run(GC.java:117)
   - locked <0x00000000a9a245e8> (a sun.misc.GC$LatencyLock)

   Locked ownable synchronizers:
   - None

"AsyncFileHandlerWriter-225534817" #14 daemon prio=5 os_prio=0 tid=0x00000000595c4800 nid=0x1970 waiting on condition [0x0000000059f5e000]
   java.lang.Thread.State: TIMED_WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x00000000a9bf5ed8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
   at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
   at java.util.concurrent.LinkedBlockingDeque.pollFirst(LinkedBlockingDeque.java:522)
   at java.util.concurrent.LinkedBlockingDeque.poll(LinkedBlockingDeque.java:684)
   at org.apache.juli.AsyncFileHandler$LoggerThread.run(AsyncFileHandler.java:145)

   Locked ownable synchronizers:
   - None

"Service Thread" #11 daemon prio=9 os_prio=0 tid=0x0000000017d71000 nid=0x3fd4 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C1 CompilerThread3" #10 daemon prio=9 os_prio=2 tid=0x0000000017d0d800 nid=0x3e4c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C2 CompilerThread2" #9 daemon prio=9 os_prio=2 tid=0x0000000017ce5000 nid=0x2de4 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C2 CompilerThread1" #8 daemon prio=9 os_prio=2 tid=0x0000000017ce1800 nid=0x374c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"C2 CompilerThread0" #7 daemon prio=9 os_prio=2 tid=0x0000000017cdb800 nid=0x438 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Attach Listener" #6 daemon prio=5 os_prio=2 tid=0x0000000017cda800 nid=0x232c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Signal Dispatcher" #5 daemon prio=9 os_prio=2 tid=0x0000000017cd0000 nid=0x17c4 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Surrogate Locker Thread (Concurrent GC)" #4 daemon prio=9 os_prio=0 tid=0x0000000017cca800 nid=0x3aec waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
   - None

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x0000000017cae000 nid=0x2c48 in Object.wait() [0x000000001764f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
   - locked <0x00000000a9a24600> (a java.lang.ref.ReferenceQueue$Lock)
   at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
   at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

   Locked ownable synchronizers:
   - None

"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x0000000017c66800 nid=0x21f4 in Object.wait() [0x000000005880f000]
   java.lang.Thread.State: WAITING (on object monitor)
   at java.lang.Object.wait(Native Method)
   at java.lang.Object.wait(Object.java:502)
   at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
   - locked <0x00000000a9bf59c8> (a java.lang.ref.Reference$Lock)
   at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

   Locked ownable synchronizers:
   - None

"VM Thread" os_prio=2 tid=0x0000000017c5c800 nid=0x2db8 runnable
"Gang worker#0 (Parallel GC Threads)" os_prio=2 tid=0x00000000021c6800 nid=0x2b8c runnable
"Gang worker#1 (Parallel GC Threads)" os_prio=2 tid=0x00000000021cb800 nid=0x2c44 runnable
"Gang worker#2 (Parallel GC Threads)" os_prio=2 tid=0x00000000021cd000 nid=0x27b8 runnable
"Gang worker#3 (Parallel GC Threads)" os_prio=2 tid=0x00000000021ce800 nid=0x3d04 runnable
"Gang worker#4 (Parallel GC Threads)" os_prio=2 tid=0x00000000021d2000 nid=0x3498 runnable
"Gang worker#5 (Parallel GC Threads)" os_prio=2 tid=0x00000000021d3000 nid=0x3ff8 runnable
"Gang worker#6 (Parallel GC Threads)" os_prio=2 tid=0x00000000021d5800 nid=0x3f2c runnable
"Gang worker#7 (Parallel GC Threads)" os_prio=2 tid=0x00000000021d6800 nid=0x3e0c runnable
"Concurrent Mark-Sweep GC Thread" os_prio=2 tid=0x0000000002249000 nid=0x2d60 runnable
"Gang worker#0 (Parallel CMS Threads)" os_prio=2 tid=0x0000000002244800 nid=0x808 runnable
"Gang worker#1 (Parallel CMS Threads)" os_prio=2 tid=0x0000000002247800 nid=0x65c runnable
"VM Periodic Task Thread" os_prio=2 tid=0x0000000017d4c000 nid=0x21b8 waiting on condition
JNI global references: 253

3 REPLIES 3

edsonrichter
Confirmed Champ
Confirmed Champ
Just to be sure: Using 5.20.0, Tomcat (7.0.68 or 8.0.33), JDK 1.8.0-91x64 on Windows Server 2008r2

edsonrichter
Confirmed Champ
Confirmed Champ
When I start running

ProcessEngines.init()

There are four threads that doesn't exists with I don't call init() method.
The threads are "RMI RenewClean", "RMI Readper", "RMI TCP Accepto-0", and "RMI TCP Accept-1099"

Would these threads be related to Activiti? How can I avoid them to start up?

edsonrichter
Confirmed Champ
Confirmed Champ
Ok, seems the deakdlock is caused by activiti-jmx library.
Removed from the system, now it is working well either on Tomcat 7 and Tomcat 8.