AnsweredAssumed Answered

NullPointerException in AbstractBpmnActivityBehavior

Question asked by eric.manuguerra on Feb 16, 2016
Latest reply on Jun 14, 2018 by geravg
Hell everybody,

I have migrated a web application from Activiti 5.8 to 5.17 and we have encountered a NPE when a subprocess is executed due to an ActivityExecution with a null activity.

The stack trace starts with :

<i>
2016-02-15 19:17:31,284 [nio-8080-exec-8] DEBUG [                          o.a.e.i.i.CommandContext] Error while closing command context
java.lang.NullPointerException
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.hasCompensationHandler(AbstractBpmnActivityBehavior.java:54)
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:43)

</i>

The  line 54 in AbstractBpmnActivityBehavior class throws a null pointer exception because execution.getActivity() returns null.


execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID) != null


We have spent a few hours debugging without being able to figure out why the execution is referencing a null activity at this point.

The full stack trace is attached. The main workflow and the subprocess are also attached.

For now I have modified the AbstractBpmnActivityBehavior class and added a test in the leave() method :


        if (execution.getActivity() != null) {
            if (hasCompensationHandler(execution)) {
                createCompensateEventSubscription(execution);
            }
            if (!hasLoopCharacteristics()) {
                super.leave(execution);
            } else if (hasMultiInstanceCharacteristics()) {
                multiInstanceActivityBehavior.leave(execution);
            }
        } else {
            logger.error("Execution with null activity {}", execution.getId());
        }


The behavior is ok, and the workflow is carried on to its end.

- Do you see a better fix for this issue ?

Thank for your help,
Best regards,
Eric



Outcomes