Search code examples
jbosspersistencejbpm

How to access process details using process instance in JBPM 6?


I started using JBPM 6.3.0 Final as per the documentation. I'm able to start a process instance and able to complete the tasks aswell.

But I'm unable to access the process details from process instance when persistence is enabled(persistence set to true). Below is my code.

ProcessInstance pi= ksession.startProcess("AssetCommissionRoutine.commission", params);
System.out.println(pi.getProcessName());

I even tried to cast it to WorkflowProcessInstance and RuleFlowProcessInstance

I get the following error when I try to access any of the process related information.

Exception in thread "main" java.lang.IllegalStateException: Process instance 1[AssetCommissionRoutine.commission] is disconnected.

Any help is much appreciated.


Solution

  • Have you tried getting the process instance again ? I know it may be immediately after the create but I had to do this to getVariable data as the process moves on when created. I am, however, getting the same error as you when trying to setVariable.

    ProcessInstance processInstance = ksession.startProcess("myclass", params);
    
    long pid = processInstance.getId();
    ProcessInstance pi2 = ksession.getProcessInstance(pid);
    RuleFlowProcessInstance rfpi = (RuleFlowProcessInstance)pi2;
    MyModel pVarMyModel = (MyModel)(rfpi.getVariable("myProcessData"));