1 2 Previous Next 25 Replies Latest reply on Jun 5, 2013 8:05 AM by sumerus

    JTA Problem with multiple sessions

    Gareth Edwards Newbie

      Hello.

       

      I am writing a system which will allow me to start instances of work-flows using a rest api as well as managing all the human tasks.

      For now I am using one instance of a KnowlegeBase which uses an EntityManagerFactory like this:

       

      if (emf == null){

                                    emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );

                                    Environment env = KnowledgeBaseFactory.newEnvironment();

                                    env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

                          }

       

      I am using a Stateful knowledge session per work-flow instance.

       

       

      JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

                        String connectorName = "Hornet" + UUID.randomUUID().toString();

       

                        AsyncHornetQHTWorkItemHandler workItemHandler = new AsyncHornetQHTWorkItemHandler(new AsyncHornetQTaskClient(connectorName), ksession, OnErrorAction.LOG);

                        workItemHandler.setIpAddress("192.168.1.90");

                                    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);

                                    ksession.startProcess(workflowSession.getWorkflowName(),workflowSession.getWorkFlowData());

                                    try {

                                              Thread.sleep(2000);

                                    } catch (InterruptedException e) {

        // TODO Auto-generated catch block

                                              e.printStackTrace();

                                    }

       

      With a clean postgres database the first completion of the human task (and end of the work-flow) I get no problems:

       

       

      15:12:54,302 INFO  [stdout] (workflowExecutor-1) Workflow Instance Variables

      15:12:54,303 INFO  [stdout] (workflowExecutor-1) agent:krisv

      15:12:54,305 INFO  [stdout] (workflowExecutor-1) test_id:TZ001A0001

      15:13:56,128 INFO  [stdout] (Thread-76) test_id is correct

      15:13:56,128 INFO  [stdout] (Thread-76) test_id:TZ001A0001

      15:13:56,128 INFO  [stdout] (Thread-76) submitted_test_id:TZ001A0001

       

      But then running the work-flow again (new session) I almost always get problems:

       

      15:14:33,869 INFO  [stdout] (workflowExecutor-2) Workflow Instance Variables

      15:14:33,870 INFO  [stdout] (workflowExecutor-2) agent:krisv

      15:14:33,870 INFO  [stdout] (workflowExecutor-2) test_id:TZ001A0001

      15:14:54,675 INFO  [stdout] (Thread-76) test_id is correct

      15:14:54,675 INFO  [stdout] (Thread-76) test_id:TZ001A0001

      15:14:54,675 INFO  [stdout] (Thread-76) submitted_test_id:TZ001A0001

      15:14:54,692 INFO  [stdout] (Thread-77) test_id is correct

      15:14:54,692 INFO  [stdout] (Thread-77) test_id:TZ001A0001

      15:14:54,693 INFO  [stdout] (Thread-77) submitted_test_id:TZ001A0001


      15:14:54,719 WARN  [com.arjuna.ats.arjuna] (Thread-77) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffff7f000101:-62cc4985:510a8991:60, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@339ec220 >: javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1394) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1308) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)

                at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)

                at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

                at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)

                at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2359) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3127) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3327) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:91) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:191) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                ... 17 more

      15:14:54,732 WARN  [org.drools.persistence.jta.JtaTransactionManager] (Thread-77) Unable to commit transaction: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)

                at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

                at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)

                at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

      Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1394) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1308) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

       

       

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)

                at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)

                ... 11 more

      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2359) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3127) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3327) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:91) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:191) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                ... 17 more

       

       

       

      15:14:54,737 ERROR [org.drools.persistence.SingleSessionCommandService] (Thread-77) Could not commit session: java.lang.RuntimeException: Unable to commit transaction

                at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:182) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

      Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)

                at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)

                at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)

                at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                ... 7 more

      Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1394) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1308) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

       

       

                at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)

                at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)

                at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)

                at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)

                ... 11 more

      Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.persistence.processinstance.ProcessInstanceInfo#11]

                at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2359) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3127) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3327) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:91) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:191) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:104) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]

                ... 17 more

       

       

      15:14:54,748 WARN  [org.drools.persistence.jta.JtaTransactionManager] (Thread-77) Unable to rollback transaction: java.lang.IllegalStateException: BaseTransaction.rollback - ARJUNA016074: no transaction!

       

       

                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.rollback(BaseTransaction.java:130)

                at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.rollback(BaseTransactionManagerDelegate.java:114)

                at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.rollback(ServerVMClientUserTransaction.java:175)

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:191) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:402) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:381) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

       

       

      15:14:54,751 ERROR [org.drools.persistence.SingleSessionCommandService] (Thread-77) Could not rollback: java.lang.RuntimeException: Unable to rollback transaction

                at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:197) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:402) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:381) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

      Caused by: java.lang.IllegalStateException: BaseTransaction.rollback - ARJUNA016074: no transaction!

                at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.rollback(BaseTransaction.java:130)


      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.rollback(BaseTransactionManagerDelegate.java:114)

      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.rollback(ServerVMClientUserTransaction.java:175)

      at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:191) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      ... 8 more

       

       

      15:14:54,754 ERROR [org.jbpm.task.service.hornetq.HornetQTaskClientConnector] (Thread-77) Client Exception with class class org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1 using port 5153: java.lang.RuntimeException: Could not commit session or rollback


      at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:406) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:381) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      at org.drools.command.impl.CommandBasedStatefulKnowledgeSession$1.completeWorkItem(CommandBasedStatefulKnowledgeSession.java:150) [drools-core-5.5.0.Final.jar:5.5.0.Final]

      at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$GetResultContentResponseHandler.execute(AsyncGenericHTWorkItemHandler.java:302) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

      at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:153) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

      at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

      at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

      at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

      Caused by: java.lang.RuntimeException: Unable to rollback transaction


      at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:197) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:402) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      ... 7 more

      Caused by: java.lang.IllegalStateException: BaseTransaction.rollback - ARJUNA016074: no transaction!


      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.rollback(BaseTransaction.java:130)

      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.rollback(BaseTransactionManagerDelegate.java:114)

      at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.rollback(ServerVMClientUserTransaction.java:175)

      at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:191) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

      ... 8 more

       

       

      I'm using the bundled human-task-war.war application to handle human tasks.

       

      The persistence for my EntityManagerFactory is configured using the following persistence.xml

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <persistence version="2.0"

        xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="

              http://java.sun.com/xml/ns/persistence

              http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

        <persistence-unit name="org.jbpm.persistence.jpa"

        transaction-type="JTA">

                          <provider>org.hibernate.ejb.HibernatePersistence</provider>

                          <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>

                          <mapping-file>META-INF/JBPMorm-JPA2.xml</mapping-file>

                          <mapping-file>META-INF/ProcessInstanceInfoMapping-JPA2.xml</mapping-file>

       

                          <class>org.drools.persistence.info.SessionInfo</class>

                          <class>org.drools.persistence.info.WorkItemInfo</class>

                          <class>org.jbpm.process.audit.ProcessInstanceLog</class>

                          <class>org.jbpm.process.audit.NodeInstanceLog</class>

                          <class>org.jbpm.process.audit.VariableInstanceLog</class>

       

        <properties>

        <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />

        <property name="hibernate.max_fetch_depth" value="3" />

        <!-- property name="hibernate.hbm2ddl.auto" value="update" /-->

        <property name="hibernate.show_sql" value="false" />

        <!--property name="hibernate.transaction.manager_lookup_class"

                                              value="org.hibernate.transaction.JBossTransactionManagerLookup" /-->

       

        <property name="hibernate.transaction.jta.platform"

        value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

       

        <!-- BZ 841786: AS7/EAP 6/Hib 4 uses new (sequence) generators which seem

                                              to cause problems -->

        <property name="hibernate.id.new_generator_mappings" value="false" />

        </properties>

       

        </persistence-unit>

      </persistence>


      I tried the change below as it was suggested by another user with similar problems with Postgres

       

        <!--property name="hibernate.transaction.manager_lookup_class"

        value="org.hibernate.transaction.JBossTransactionManagerLookup" /-->

       

        <property name="hibernate.transaction.jta.platform"

        value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

       

      But that didn't seem to help.

       

      I hope somebody can help

       

      Thanks in advance,

       

      Gareth.

        • 1. Re: JTA Problem with multiple sessions
          Maciej Swiderski Master

          Gareth, I believe that this is caused by multiple session listening on completed tasks events and when second task is completed (from another process that was started by new session) events are sent to all listeners - meaning two sessions and both will try to resume process and thus optimistic locking exception. You can instruct the work item handler to only react on tasks completed events that were created by given session by setting workitemhandler.setOwningSessionOnly(true) that should ensure only session that created the task will consume its completed task event. Please not that this forces you to use same session (with same id) to resume process after task was completed.

           

          HTH

          • 2. Re: JTA Problem with multiple sessions
            vchmakov Newbie

            Hi Maciej,

             

            This means that in an environment with multiple sessions processing users’ requests in parallel when a request for a task completion arrives on a message bus and the setOwingSession() flag is TRUE and the owing session is given to the other thread for execution the conflict is also inevitable. Correct?

            What is the best practice to avoid the conflict? Or to rephrase the questions – what is the right way to scale out the solution?

             

            Thanks,

             

            Vladimir

            1 of 1 people found this helpful
            • 3. Re: JTA Problem with multiple sessions
              Gareth Edwards Newbie

              Thanks a lot!

               

              Now I just need to work out how I know a work-flow has ended so I can dispose of the session.

              I'm guessing there is a handler for that?

               

              Gareth.

              • 4. Re: JTA Problem with multiple sessions
                Maciej Swiderski Master

                Vladimir, not sure I I got your question right. Once you have a handler (HTWorkItemHandler) configured to react only on its tasks (created by that session) conflicts should not happen. What you mean by "session is given to the other thread for execution"? If you just move that processing to separate thread it still should not be an issue as only single session will receive that event. Did I got your question right?

                 

                HTH

                • 5. Re: JTA Problem with multiple sessions
                  Maciej Swiderski Master

                  you could look at ProcessEventListener to get notification on process completion.

                   

                  HTH

                  1 of 1 people found this helpful
                  • 6. Re: JTA Problem with multiple sessions
                    Gareth Edwards Newbie

                    There it is page 302.  Thanks again!

                    • 7. Re: JTA Problem with multiple sessions
                      Gareth Edwards Newbie

                      I now have a problem a few people seem to have:

                       

                      Illegal method call. This session was previously disposed.

                       

                      As soon as the session is disposed:

                      [com.arjuna.ats.jta] (Thread-90) ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.drools.persistence.jta.JtaTransactionSynchronizationAdapter@15f026b6 with exception: java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                       

                      Gareth.

                      • 8. Re: JTA Problem with multiple sessions
                        vchmakov Newbie

                        Hi Maciej,

                         

                        Please consider the following scenario. There are two sessions in an environment to execute requests in parallel – S1 and S2. Task Service is local – which is important for this discussion.

                        1. ) User A (UA) requesting to start a process which produces a Human Task. Thread 1 (T1) jumping up, picking up S1, executing the workflow and producing a Human Task (HT1).
                        2. ) User B (UB) requesting to execute something. Thread 1 (T1) jumping up, picking up S1 and starting doing something.
                        3. ) At the same time user C (UC) completing the HT1. T2 jumping up and seeing that HT1 belongs to S1. OK, the handler is picking up S1, executing the completeTask() command and resuming the workflow on S1. Here comes the conflict, because S1 is busy doing things on T1.

                         

                        According to your description above it seems like there is no workaround, because if we’d set OwingSession to FALSE both S1 and S2 would receive notification. Correct? If this is correct then what session would be used for completing task in this case? I believe regardless of the answer the conflict is inevitable. Correct?

                         

                        Thanks,

                         

                        Vladimir

                        • 9. Re: JTA Problem with multiple sessions
                          Maciej Swiderski Master

                          Take a look here, might be useful for your case.

                           

                          HTH

                          • 10. Re: JTA Problem with multiple sessions
                            Maciej Swiderski Master

                            Vladimir, in general as for all stuff that stores data in db you can run into conflicts if you update same data at the same time. Although session should synchronize access on process instance level so if multiple threads will operate on same session and same process instance that should not lead to a conflict.

                             

                            HTH

                            • 11. Re: JTA Problem with multiple sessions
                              vchmakov Newbie

                              Hi Maciej,

                               

                              Are you saying that Session is now thread safe – it used to be different?

                               

                              Thanks,

                               

                              Vladimir

                              • 12. Re: JTA Problem with multiple sessions
                                Maciej Swiderski Master

                                how did you go to that conclusion? What I said is that session will synchronize access to process isntance to only single thread.

                                 

                                HTH

                                • 13. Re: JTA Problem with multiple sessions
                                  Gareth Edwards Newbie

                                  I am now

                                  ksession.addEventListener(new DefaultProcessEventListener(){

                                    @Override

                                                                          public void afterProcessCompleted(ProcessCompletedEvent event){

                                                                                    System.out.println("Disposing of " + event.getProcessInstance().getProcessName() + "!");

                                                                                    ksession.execute(new CMTDisposeCommand());

                                                                          }

                                                                });

                                   

                                  I am creating a session and running an instance of a work-flow in it and then completing the workflow and disposing the session.

                                  I then create another session and another work-flow instance in the new session.

                                  This does not throw an error after completing the first work-flow on first session but now throws the exception when completing the next session of the next work-flow.

                                   

                                  17:04:28,939 INFO  [stdout] (http--0.0.0.0-8080-2) WorkflowProcessInstance1 [processId=TrakCel.DataTest,state=1]

                                  17:04:28,939 INFO  [stdout] (http--0.0.0.0-8080-2) Workflow Instance Variables

                                  17:04:28,939 INFO  [stdout] (http--0.0.0.0-8080-2) agent:krisv

                                  17:04:28,939 INFO  [stdout] (http--0.0.0.0-8080-2) test_id:TZ001A0001

                                  17:04:56,464 INFO  [stdout] (Thread-75) Test is incorrect

                                  17:04:56,465 INFO  [stdout] (Thread-75) trakzone_id:TZ001A0001

                                  17:04:56,465 INFO  [stdout] (Thread-75) scanned_test_idTZ001A0001A

                                  17:04:56,475 INFO  [stdout] (Thread-75) Disposing of DataTest!

                                   

                                  At this point the fiest session has been disposed with no errors.

                                  A new session and work-flow instance is started

                                   

                                  17:09:53,795 INFO  [stdout] (http--0.0.0.0-8080-3) WorkflowProcessInstance3 [processId=Package1.DataTest,state=1]

                                  17:09:53,796 INFO  [stdout] (http--0.0.0.0-8080-3) Workflow Instance Variables

                                  17:09:53,796 INFO  [stdout] (http--0.0.0.0-8080-3) agent:krisv

                                  17:09:53,796 INFO  [stdout] (http--0.0.0.0-8080-3) test_id:TZ001A0001

                                  17:10:15,571 ERROR [org.drools.persistence.SingleSessionCommandService] (Thread-75) Could not commit session: java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                                            at org.drools.reteoo.DisposedReteooWorkingMemory.getId(DisposedReteooWorkingMemory.java:98) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.impl.StatefulKnowledgeSessionImpl.getId(StatefulKnowledgeSessionImpl.java:137) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.runtime.GetIdCommand.execute(GetIdCommand.java:41) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.runtime.GetIdCommand.execute(GetIdCommand.java:28) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:119) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$TaskCompletedHandler.execute(AsyncGenericHTWorkItemHandler.java:232) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:204) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

                                  17:10:15,574 WARN  [com.arjuna.ats.jta] (Thread-75) ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.drools.persistence.jta.JtaTransactionSynchronizationAdapter@7a947037 with exception: java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                                            at org.drools.reteoo.DisposedReteooWorkingMemory.getProcessRuntime(DisposedReteooWorkingMemory.java:270) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.impl.StatefulKnowledgeSessionImpl.getProcessRuntime(StatefulKnowledgeSessionImpl.java:874) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.SingleSessionCommandService$SynchronizationImpl.afterCompletion(SingleSessionCommandService.java:455) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.afterCompletion(JtaTransactionSynchronizationAdapter.java:25) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:96)

                                            at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:402)

                                            at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:334)

                                            at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.cancel(TwoPhaseCoordinator.java:120)

                                            at com.arjuna.ats.arjuna.AtomicAction.abort(AtomicAction.java:188)

                                            at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.rollbackAndDisassociate(TransactionImple.java:1247)

                                            at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.rollback(BaseTransaction.java:134)

                                            at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.rollback(BaseTransactionManagerDelegate.java:114)

                                            at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.rollback(ServerVMClientUserTransaction.java:175)

                                            at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:191) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:402) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:381) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:119) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$TaskCompletedHandler.execute(AsyncGenericHTWorkItemHandler.java:232) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:204) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

                                   

                                   

                                  17:10:15,600 WARN  [com.arjuna.ats.arjuna] (Thread-75) ARJUNA012127: TwoPhaseCoordinator.afterCompletion - returned failure for SynchronizationImple< 0:ffff7f000101:-1da4df24:510d461b:6f, org.drools.persistence.jta.JtaTransactionSynchronizationAdapter@7a947037 >

                                  17:10:15,605 ERROR [org.jbpm.task.service.hornetq.HornetQTaskClientConnector] (Thread-75) Client Exception with class class org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1 using port 5153: java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

                                            at org.drools.reteoo.DisposedReteooWorkingMemory.getId(DisposedReteooWorkingMemory.java:98) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.impl.StatefulKnowledgeSessionImpl.getId(StatefulKnowledgeSessionImpl.java:137) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.runtime.GetIdCommand.execute(GetIdCommand.java:41) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.runtime.GetIdCommand.execute(GetIdCommand.java:28) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:373) [drools-persistence-jpa-5.5.0.Final.jar:5.5.0.Final]

                                            at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.getId(CommandBasedStatefulKnowledgeSession.java:119) [drools-core-5.5.0.Final.jar:5.5.0.Final]

                                            at org.jbpm.process.workitem.wsht.AsyncGenericHTWorkItemHandler$TaskCompletedHandler.execute(AsyncGenericHTWorkItemHandler.java:232) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:204) [jbpm-human-task-core-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientHandler.messageReceived(HornetQTaskClientHandler.java:56) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at org.jbpm.task.service.hornetq.HornetQTaskClientConnector$1.run(HornetQTaskClientConnector.java:122) [jbpm-human-task-hornetq-5.4.0.Final.jar:5.4.0.Final]

                                            at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]

                                   

                                  17:10:15,651 INFO  [stdout] (Thread-76) Test is incorrect

                                  17:10:15,652 INFO  [stdout] (Thread-76) test_id:TZ001A0001

                                  17:10:15,652 INFO  [stdout] (Thread-76) scanned_test_idTZ001A0001A

                                  17:10:15,661 INFO  [stdout] (Thread-76) Disposing of DataTest!

                                   

                                  So now the error is not after the dispose but when completing the sencond instance of the second session.

                                   

                                  The work-flow is very simple start -> human task to get test_id -> XOR -> script task to print success or script task to print fail -> end

                                   

                                  Gareth.

                                  • 14. Re: JTA Problem with multiple sessions
                                    Maciej Swiderski Master

                                    Gareth, when you dispose the session you need to dispose all other components that rely on the session, in your case its ht handler. What you could do it to pass the ht handler to process event listener so it can be disposed (disconnected) when session is disposed as well. This assumption is that you have one to one relationship between all three instances: ksession, ht handler and process event listener that disposes the session and handler.

                                     

                                    HTH

                                    1 2 Previous Next