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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.