cancel
Showing results for 
Search instead for 
Did you mean: 

When do ProcessInstances and Tasks get Persisted

activuser
Champ in-the-making
Champ in-the-making
Hello,

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.
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Could you create jUnit test for the issue?
https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

activuser
Champ in-the-making
Champ in-the-making
Hi Martin,

Sorry I cannot provide a unit test due to client confidentiality. Also I don't see why you need one since I asked a simple question:

WHEN does the Process Instance and Tasks get persisted?


Thanks,

Tim