Why does ProcessInstance throw an RuntimeException: Process instance XXX is disconnected or NPE on invocation of its method in BPMS ?

Solution Verified - Updated -

Issue

  • I am starting a process that goes to wait state and will only resume upon receiving a signal. While the process instance is in wait state, I am trying is to get some info on the process instance (using getter methods like getProcessName() ) . I have observed, if I start the process instance using the following way [1] then it works fine, otherwise if I use the other approach [2] it complains with a NullPointerException as shown below [3] inside the stack trace.
    Can you please advise what is the correct approach amongst [1] & [2] and why it complains the NullPointerException ?

[1]

StatefulKnowledgeSession statefulKnowledgeSession = JPAKnowledgeService.newStatefulKnowledgeSession(kb,null,env);
ProcessInstance processInstance = knowledgeSession.createProcessInstance(processName, params);
knowledgeSession.startProcessInstance(processInstance.getId());

[2]

StatefulKnowledgeSession statefulKnowledgeSession = JPAKnowledgeService.newStatefulKnowledgeSession(kb,null,env);
ProcessInstance processInstance = knowledgeSession.createProcessInstance(processName, params);
processInstance.start();

[3]

java.lang.NullPointerException
        at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
        at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcessName(ProcessInstanceImpl.java:81)
        ...
  • I get NullPointerException when I call WorkflowProcessInstance.setVariable().
java.lang.NullPointerException
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:67)
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.getContextInstance(ProcessInstanceImpl.java:127)
    at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.setVariable(WorkflowProcessInstanceImpl.java:238)
    at com.sample.ProcessTest.testProcess(ProcessTest.java:60)
...
  • I get RuntimeException when I call ProcessInstance.getProcess() in BPMS 6.1.
java.lang.RuntimeException: Process instance 1[com.sample.bpmn.hello] is disconnected.
    at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:100)
    at com.sample.ProcessJPATest.testProcess(ProcessJPATest.java:101)
  • I get RuntimeException when I call JbpmJUnitBaseTestCase.assertNodeActive() in BPMS 6.1.
java.lang.RuntimeException: Process instance 1[com.sample.bpmn.hello] is disconnected.
        at org.jbpm.process.instance.impl.ProcessInstanceImpl.getProcess(ProcessInstanceImpl.java:100)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getWorkflowProcess(WorkflowProcessInstanceImpl.java:227)
        at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.getNodeContainer(WorkflowProcessInstanceImpl.java:85)
        at org.jbpm.workflow.instance.impl.NodeInstanceImpl.getNode(NodeInstanceImpl.java:121)
        at org.jbpm.workflow.instance.node.WorkItemNodeInstance.getNodeName(WorkItemNodeInstance.java:383)
        at org.jbpm.test.JbpmJUnitBaseTestCase.assertNodeActive(JbpmJUnitBaseTestCase.java:677)
        at org.jbpm.test.JbpmJUnitBaseTestCase.assertNodeActive(JbpmJUnitBaseTestCase.java:664)
        at com.sample.ProcessTest.testProcess(ProcessTest.java:30)

Environment

  • JBoss Enterprise Business Rules Management System (BRMS)
    • 5.3.0
  • Red Hat JBoss BPM Suite (BPMS)
    • 6
  • jBPM
    • 5
    • 6

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