How to start new process instance from custom WorkItemHandler in JBoss BPM Suite 6 ?
Issue
In custom workItemHandler we are using below code to start new process instance, but it fails with exception:
//execute method:
long processInstanceId = workItem.getProcessInstanceId();
ProcessInstance ins = kSession.getProcessInstance(processInstanceId);
String processId = ins.getProcessId();
ProcessInstance procInstance = kSession.startProcess(processId, null);
long newProcessInstanceId = procInstance.getId();
Exception:
. . .
Caused by: java.lang.IllegalStateException: KieSession with id 12 is already used by another context
at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.validate(PerProcessInstanceRuntimeManager.java:165) [jbpm-runtime-manager-6.2.0.Final-redhat-4.jar:6.2.0.Final-redhat-4]
at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:92) [jbpm-persistence-jpa-6.2.0.Final-redhat-4.jar:6.2.0.Final-redhat-4]
. . .
Environment
- Red Hat JBoss BPM Suite
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.