Error boundary event did not work

Showing results for 
Search instead for 
Did you mean: 
Member II

Error boundary event did not work


I'm trying to handle exceptions from a subprocess with a parallel gateway. I expect the subprocess to run into and endEvent with failure, but it didn't. The process is defined as follows:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns=""
    <process id="ErrSubParallelTest" name="Parallel wait">
        <documentation>Asynchorous nonexclusive parallel process</documentation>
        <startEvent id="start" name="Test Start"/>
        <subProcess id="subprocess" name="Sub Process">
            <startEvent id="startSub" name="Sub Process Start"/>
            <parallelGateway id="fork" name="Parallel Gateway Fork"/>
            <scriptTask id="wait1" name="wait 1" scriptFormat="groovy" activiti:async="true" activiti:exclusive="false">
                    long a = 1/0;
            <scriptTask id="wait2" name="wait 2" scriptFormat="groovy" activiti:async="true" activiti:exclusive="false">
                    out:println "wait thread 2 start";
                    out:println "wait thread 2 continue";
                    out:println "wait thread 2 end";
            <scriptTask id="wait3" name="wait 3" scriptFormat="groovy" activiti:async="true" activiti:exclusive="false">
                    out:println "wait thread 3 start";
                    out:println "wait thread 3 continue";
                    out:println "wait thread 3 end";
            <receiveTask id="view1" name="rcv1" activiti:async="true" activiti:exclusive="false"/>
            <receiveTask id="view2" name="rcv2" activiti:async="true" activiti:exclusive="false"/>
            <receiveTask id="view3" name="rcv3" activiti:async="true" activiti:exclusive="false"/>
            <parallelGateway id="join" name="Parallel Gateway Join"/>
            <endEvent id="endSub" name="Sub process end"/>

            <sequenceFlow id="flow1" name="" sourceRef="startSub" targetRef="fork"/>
            <sequenceFlow id="flow2" name="" sourceRef="fork" targetRef="wait1"/>
            <sequenceFlow id="flow3" name="" sourceRef="fork" targetRef="wait2"/>
            <sequenceFlow id="flow4" name="" sourceRef="fork" targetRef="wait3"/>
            <sequenceFlow id="flow5" name="" sourceRef="wait1" targetRef="view1"/>
            <sequenceFlow id="flow6" name="" sourceRef="wait2" targetRef="view2"/>
            <sequenceFlow id="flow7" name="" sourceRef="wait3" targetRef="view3"/>
            <sequenceFlow id="flow8" name="" sourceRef="view1" targetRef="join"/>
            <sequenceFlow id="flow9" name="" sourceRef="view2" targetRef="join"/>
            <sequenceFlow id="flow10" name="" sourceRef="view3" targetRef="join"/>
            <sequenceFlow id="flow11" name="" sourceRef="join" targetRef="endSub"/>
        <boundaryEvent id="catchError" attachedToRef="subprocess">
            <errorEventDefinition errorRef="AIA_ERROR_99"/>
        <endEvent id="end" name="End test">

        <sequenceFlow id="flow12" name="" sourceRef="start" targetRef="subprocess"/>
        <sequenceFlow id="flow13" name="" sourceRef="catchError" targetRef="end"/>

To catch the exception thrown from wait1, I implemented an event listener:

public class GlobalEventListener implements ActivitiEventListener {
    public void onEvent(ActivitiEvent event) {
        ActivitiEventType type = event.getType();
if (type.equals(ActivitiEventType.JOB_EXECUTION_FAILURE)) {
            System.out.println("Get Job execution failure.");
throw new BpmnError("AIA_ERROR_99");

    public boolean isFailOnException() {
return false;

Then I deployed the process, and started it. The flow didn't terminate when JOB_EXCUTION_FAILURE was captured. Instead, wait1 retried for three times before it suspended.

Did I make things wrong? Any help will be appreciated!

1 Reply
Established Member II

Re: Error boundary event did not work


I see in your 'wait1' scriptTask:

<scriptTask id="wait1" name="wait 1" scriptFormat="groovy" activiti:async="true" activiti:exclusive="false">
      long a = 1/0;

You're dividing by zero, which in Javascript doesn't cause any errors as it is then concluded as 'Infinity' - however, in Groovy and Java, this same code snippet would conclude with an "java.lang.ArithmeticException: / by zero" error. I imagine that's your intention, and you're trying to catch this exception, correct?

However, as stated in the User Guide, the behavior you're describing is intended:

  • "Activiti, in its default configuration, reruns a job 3 times in case of any exception in execution of a job. This holds also for asynchronous task jobs."