I have a requirement to get the list of all active instances along with the tasks under every instance. I did the below but unable to retrieve the tasks under the instance. Appreciate any pointers.
//Get the list of all active process instances
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().active().list();
//Iterate through the instances and cast it to ExecutionEntity to get more info.
for(ProcessInstance processInstance : data) {
ExecutionEntity entity = (ExecutionEntity)processInstance;
for(TaskEntity task : entity.getTasks()) {
...
}
}While performing entity.getTasks(), it throws a NPE.
java.lang.NullPointerException: null
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.ensureTasksInitialized(ExecutionEntity.java:1391)
Looks like Context.getCommandContext() inside the ensureTasksInitialized method is returning null.
How do I get around this problem? Isn't the correct way of retrieving the tasks under an instance?