cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException in ExecutionEntity

iravanchi
Champ in-the-making
Champ in-the-making
Hi,

I want to display a list of running process instances in my UI, and here's what I did:

Called runtimeService.createProcessInstanceQuery().list();
For each of them
{
    called repositoryService.findProcessDefinitionById(processInstance.getProcessDefinitionId()) to get the definition name.
    called processInstance.findActiveActivityIds()
}

In the last line, I get an exception as follows:

Caused by: java.lang.NullPointerException
   at org.activiti.engine.impl.runtime.ExecutionEntity.ensureProcessDefinitionInitialized(ExecutionEntity.java:195)
   at org.activiti.pvm.impl.runtime.ExecutionImpl.getProcessDefinition(ExecutionImpl.java:296)
   at org.activiti.engine.impl.runtime.ExecutionEntity.ensureActivityInitialized(ExecutionEntity.java:235)
   at org.activiti.pvm.impl.runtime.ExecutionImpl.collectActiveActivityIds(ExecutionImpl.java:274)
   at org.activiti.pvm.impl.runtime.ExecutionImpl.findActiveActivityIds(ExecutionImpl.java:269)
   …

Note: this was the first thing requested from the engine when the process is run.
By looking at the code, I guess this happens when the process definition is loaded in a way that doesn't parse the process definition. When we call findActiveActivityIds it tries to load and parse the definition too. I guess (I'm not sure) that CommandContext.getCurrent() is returning null when called in this context.

Should I add this to JIRA?
And is there a better way to do what I was doing originally?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
Congrats, you have found a bug 😉

Actually, the findActiveActivityIds() should be removed from the ProcessInstance and you should use the getActiveActivityIds() on the runtimeService instead.

I have removed the operation from the ProcessInstance interface.

iravanchi
Champ in-the-making
Champ in-the-making
Well, in general, should I report such issues in JIRA?
I haven't seen any clear guideline on when to report bugs on JIRA.
I already have an account, but I'm not sure when to use it.

jbarrez
Star Contributor
Star Contributor
Yes, if you find such a bug, please put it in Jira. So the guideline is: if something is not as you expect it, report it!

Even if it is not a real bug, we learn how end users are using Activiti.