2 Replies Latest reply on Jun 20, 2013 1:33 PM by pzamudio

    Jbpm 6.0.0.beta2 error disposing ksession when commiting transaction

    pzamudio

      We are testing Jbpm 6.0.0.beta2 and we get an error when working inside JBoss7, in a CMT environment.

      We are using a PerRequestRuntimeManager, so with the new apis, in a CMT environment, as soon as the transaction is commited, DisposeSessionTransactionSynchronization should dispose ksession and delete it from database.

      The error happens when the tx sync tries to delete ksession from db, because it tries to join the current transaction, which has been closed, so errors of transaction closed appears.

      Looking at tests cases in source code, the test PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction() has exactly the problem i am describing. The test gives green results, but in console appears the exceptions as warnings. When running over JBoss7, this exceptions turns to errors, because the server tries to make rollback of the current transaction (which is already commited).

       

      The exact exception in testcase is:

      3714 10/06 18:10:23,737[main] WARN  hibernate.ejb.AbstractEntityManagerImpl.joinTransaction  - HHH000326: Cannot join transaction: do not override hibernate.transaction.factory_class

      3715 10/06 18:10:23,738[main] WARN  drools.persistence.SingleSessionCommandService.rollbackTransaction  - Could not commit session

      javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call

                at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1223)

                at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1173)

                at org.drools.persistence.jpa.JpaPersistenceContext.joinTransaction(JpaPersistenceContext.java:42)

                at org.drools.persistence.SingleSessionCommandService.destroy(SingleSessionCommandService.java:428)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:36)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:22)

                at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:347)

                at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.destroy(CommandBasedStatefulKnowledgeSession.java:239)

                at org.jbpm.runtime.manager.impl.PerRequestRuntimeManager.disposeRuntimeEngine(PerRequestRuntimeManager.java:52)

                at org.jbpm.runtime.manager.impl.tx.DisposeSessionTransactionSynchronization.afterCompletion(DisposeSessionTransactionSynchronization.java:22)

                at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.afterCompletion(JtaTransactionSynchronizationAdapter.java:22)

                at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:497)

                at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:244)

                at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)

                at org.jbpm.runtime.manager.PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction(PerRequestRuntimeManagerTest.java:158)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      3717 10/06 18:10:23,740[main] WARN  persistence.jta.JtaTransactionManager.rollback  - Unable to rollback transaction

      java.lang.IllegalStateException: transaction is done, cannot change its status

                at bitronix.tm.BitronixTransaction.setRollbackOnly(BitronixTransaction.java:291)

                at bitronix.tm.BitronixTransactionManager.setRollbackOnly(BitronixTransactionManager.java:150)

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:201)

                at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:405)

                at org.drools.persistence.SingleSessionCommandService.destroy(SingleSessionCommandService.java:439)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:36)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:22)

                at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:347)

                at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.destroy(CommandBasedStatefulKnowledgeSession.java:239)

                at org.jbpm.runtime.manager.impl.PerRequestRuntimeManager.disposeRuntimeEngine(PerRequestRuntimeManager.java:52)

                at org.jbpm.runtime.manager.impl.tx.DisposeSessionTransactionSynchronization.afterCompletion(DisposeSessionTransactionSynchronization.java:22)

                at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.afterCompletion(JtaTransactionSynchronizationAdapter.java:22)

                at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:497)

                at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:244)

                at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)

                at org.jbpm.runtime.manager.PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction(PerRequestRuntimeManagerTest.java:158)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      3718 10/06 18:10:23,741[main] ERROR drools.persistence.SingleSessionCommandService.rollbackTransaction  - Could not rollback

      java.lang.RuntimeException: Unable to rollback transaction

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:205)

                at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:405)

                at org.drools.persistence.SingleSessionCommandService.destroy(SingleSessionCommandService.java:439)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:36)

                at org.drools.core.command.runtime.DestroySessionCommand.execute(DestroySessionCommand.java:22)

                at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:347)

                at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.destroy(CommandBasedStatefulKnowledgeSession.java:239)

                at org.jbpm.runtime.manager.impl.PerRequestRuntimeManager.disposeRuntimeEngine(PerRequestRuntimeManager.java:52)

                at org.jbpm.runtime.manager.impl.tx.DisposeSessionTransactionSynchronization.afterCompletion(DisposeSessionTransactionSynchronization.java:22)

                at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.afterCompletion(JtaTransactionSynchronizationAdapter.java:22)

                at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:497)

                at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:244)

                at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)

                at org.jbpm.runtime.manager.PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction(PerRequestRuntimeManagerTest.java:158)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      Caused by: java.lang.IllegalStateException: transaction is done, cannot change its status

                at bitronix.tm.BitronixTransaction.setRollbackOnly(BitronixTransaction.java:291)

                at bitronix.tm.BitronixTransactionManager.setRollbackOnly(BitronixTransactionManager.java:150)

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:201)

                ... 39 more

      3721 10/06 18:10:23,744[main] WARN  drools.persistence.SingleSessionCommandService.rollbackTransaction  - Could not commit session

      java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                at org.drools.core.reteoo.DisposedReteooWorkingMemory.getId(DisposedReteooWorkingMemory.java:97)

                at org.drools.core.impl.StatefulKnowledgeSessionImpl.getId(StatefulKnowledgeSessionImpl.java:140)

                at org.drools.core.command.runtime.GetIdCommand.execute(GetIdCommand.java:41)

                at org.drools.core.command.runtime.GetIdCommand.execute(GetIdCommand.java:28)

                at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376)

                at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:106)

                at org.jbpm.runtime.manager.PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction(PerRequestRuntimeManagerTest.java:163)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      3722 10/06 18:10:23,745[main] WARN  bitronix.tm.BitronixTransaction.fireAfterCompletionEvent  - Synchronization.afterCompletion() call failed for org.drools.persistence.jta.JtaTransactionSynchronizationAdapter@117efa0

      java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                at org.drools.core.reteoo.DisposedReteooWorkingMemory.getProcessRuntime(DisposedReteooWorkingMemory.java:261)

                at org.drools.core.impl.StatefulKnowledgeSessionImpl.getProcessRuntime(StatefulKnowledgeSessionImpl.java:868)

                at org.drools.persistence.SingleSessionCommandService$SynchronizationImpl.afterCompletion(SingleSessionCommandService.java:485)

                at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.afterCompletion(JtaTransactionSynchronizationAdapter.java:25)

                at bitronix.tm.BitronixTransaction.fireAfterCompletionEvent(BitronixTransaction.java:497)

                at bitronix.tm.BitronixTransaction.rollback(BitronixTransaction.java:283)

                at bitronix.tm.BitronixTransactionManager.rollback(BitronixTransactionManager.java:129)

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:199)

                at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:405)

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:384)

                at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:106)

                at org.jbpm.runtime.manager.PerRequestRuntimeManagerTest.testCreationOfSessionWithinTransaction(PerRequestRuntimeManagerTest.java:163)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                at java.lang.reflect.Method.invoke(Method.java:601)

                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)

                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)

                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

                at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)

                at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)

                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

                at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)