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.