Terminate End Event not killing the process

Hi everyone,

I’m getting a problem while trying to kill a process.
Here is the diagram:


Basically, I need to be able to kill the process in several steps.
The mechanism is the following:
for aborting a process I trigger either take-in-charge cancellation event or edit-draft cancellation event or close-hr cancellation event or add-logistic cancellation event.

In the ExecutionListener attached to the BoundaryCatchEvent I correlate the abort process event.

Here is the code:

public class CamundaMessageHandler implements ExecutionListener {

    public void notify(DelegateExecution delegateExecution) throws Exception {

        Long mutationId = (Long) delegateExecution.getVariable(HRMutationProcessDefinitions.ProcessVariables.MUTATION_ID);

                .processInstanceVariableEquals(HRMutationProcessDefinitions.ProcessVariables.MUTATION_ID, mutationId).correlate();

while there is no logic in the ExecutionListener attached to the start event of the EventSubProcess (I just attach it for receiving the event).

It works somehow because the “Revert new mutation data” successfully modify my DB and the '‘Undo new Mutation message’ properly send the e-mail it is supposed to send.

The problem is that the terminate end event doesn’t kill the process but throws an exception instead.
(I’m sorry but I can’t put the whole stacktrace)

16:30:34,729 SEVERE [org.camunda.bpm.engine.impl.interceptor.CommandContext] (http-/ Error while closing command context: java.lang.NullPointerException
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.getFlowScopeExecution(PvmExecutionImpl.java:1152) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createActivityExecutionMapping(PvmExecutionImpl.java:1142) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior$ErrorDeclarationFinder.collect(AbstractBpmnActivityBehavior.java:248) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior$ErrorDeclarationFinder.collect(AbstractBpmnActivityBehavior.java:223) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.tree.TreeWalker.walkUntil(TreeWalker.java:72) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.propagateError(AbstractBpmnActivityBehavior.java:124) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.propagateExceptionAsError(AbstractBpmnActivityBehavior.java:94) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.execute(ServiceTaskDelegateExpressionActivityBehavior.java:137) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:42) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:27) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:134) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:494) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:484) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:464) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:56) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:26) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:65) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:134) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:494) [camunda-engine-7.3.0.jar:7.3.0]
	at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:473) [camunda-engine-7.3.0.jar:7.3.0]

I think the problem is after the send task because if the problem were there I guess I should get a ProcessEngineException instead and so not send any recover e-mail.
So, according to this

Camunda Transaction

I should be outside the transaction border of '‘Undo new Mutation message’ send task.

Which makes me think about the terminate end event but I don’t see what the problem could be.
And the processInstance stays of course in the previous stable state which is the userTask receiving the cancellation message (no matter which one).

Any help/idea???

thanks in advance,



Hi Paolo,

Please provide a failing test case. That makes it easier to understand what is going on. See this post for how to do that: Providing a Process Engine Unit Test


Hi Thorben,

I tried to reproduce the test case.
I cloned the testcase project and I added my stuff.
I tried to attach it but the file format is not allowed(.zip).
I also created a new branch and tried to push it via git but I got 403 error.

How can I provide you with the test case?



Hi Paolo,

You can fork the unittest github repository to your own github user and push into that fork (see the Fork button on the top right of the github project page). That should not result in an authorization exception. Let me know if anything is unclear.



I’ve solved the problem!!
The key of the solution comes from this post on Stackoverflow:

(I’m sorry but I can’t put more than 1 link per post :wink:)

I try to explain the old/wrong solution and new/working one.


-UserTask with boundary catch event attached
-Event subprocess supposed to terminate the process

Use Case:

-A message is thrown and received from the boundary catch event
-The userTask is cancelled.
-In the executionListener attached to the UserTask, correlation of a message-event in charge of triggering a terminate event-subprocess

This was actually the problem.
According to the testCase I built, the subprocess was being triggered twice so the second time I was getting an error because the process engine was attempting to kill an already dead process.
That led me to a NulllValueException (among all others…)


-UserTask with boundary catch event attached
-SendTask attached to the boundary catch event (Notice: the event is a cancelling one)
-Event subprocess supposed to terminate the process


-A message is thrown and received from the boundary catch event
-The userTask is cancelled.
-the only possible path for the process become the SendTask
-correlation of a message-event (from the SendTask) in charge of triggering a terminate event-subprocess

This solution lets the process gracefully terminte.

Here is a simplified bpmn diagram:

Process diagram

Anyway, I still don’t understand why by correlating the abort message from the executionListener, the event subProcess was triggered twice…could anybody explain why??

Thanks in advance,