AnsweredAssumed Answered

When do ProcessInstances and Tasks get Persisted

Question asked by activuser on Nov 4, 2015
Latest reply on Nov 10, 2015 by activuser

I am using Activiti at a client site. I am getting a NullPointerException in my code as follows:

Process Definition starts, has 1 Java Task followed by a sub-workflow. The sub-workflow has a Java task followed by a Timer task.

In my code I:

(1) start an instance with:    runtimeService.startProcessInstanceByKey(MY_KEY);
(2)  try to query for the ProcessInstance in order to get process variables in the second Java task mentioned above

The NPE occurs because:

ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
ProcessInstance instance = query.processDefinitionKey(MY_KEY).variableValueEquals(MY_ID, id).singleResult();  // returns null

Then when I use instance.getProcessInstanceId() to send to runtimeService.getVariable a NPE occurs due to the instance being null.

Please can someone tell me when Activity persists the instance, variables etc that were created when the instance was started?

Thank you.