How to start new process instance from custom WorkItemHandler in JBoss BPM Suite 6 ?

Solution Unverified - Updated -

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.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content