cancel
Showing results for 
Search instead for 
Did you mean: 

ErrorBoundryEvent Usage Question

richard1
Champ in-the-making
Champ in-the-making
Hello All,
  We are trying to understand how the ErrorBoundryEvent works. We have created a workflow that contains a SubProcess that has an ErrorBoundryEvent attached to it. In the SubProcess we have a ScriptTask that throws an error. The error thrown from the script never makes it to the BoundryEvent. We get this error 'org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: java.lang.Exception: The Error'. This error is valid because or ScriptTask is throwing it, but what is not happening is the BoundryEvent catching it. Below is our process, what are we not understanding? We are trying to have a path for any general errors that may be thrown in anywhere in our sub proccess.


  <process id="helloworld" name="helloworld">
    <startEvent id="startevent3" name="Start"></startEvent>
    <endEvent id="endevent4" name="End"></endEvent>
    <subProcess id="subprocess2" name="Sub Process">
      <startEvent id="subprocess2startevent4" name="Start"></startEvent>
      <endEvent id="subprocess2endevent5" name="End"></endEvent>
      <scriptTask id="subprocess2scripttask3" name="Script Task" scriptFormat="groovy">
        <script><![CDATA[throw new Exception('The Error');]]></script>
      </scriptTask>
      <sequenceFlow id="subprocess2flow8" name="" sourceRef="subprocess2startevent4" targetRef="subprocess2scripttask3"></sequenceFlow>
      <sequenceFlow id="subprocess2flow9" name="" sourceRef="subprocess2scripttask3" targetRef="subprocess2endevent5"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow10" name="" sourceRef="startevent3" targetRef="subprocess2"></sequenceFlow>
    <sequenceFlow id="flow11" name="" sourceRef="subprocess2" targetRef="endevent4"></sequenceFlow>
    <boundaryEvent id="boundaryerror3" name="CrappHappening" attachedToRef="subprocess2">
      <errorEventDefinition></errorEventDefinition>
    </boundaryEvent>
    <scriptTask id="scripttask4" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[println('We Have Error Happening");]]></script>
    </scriptTask>
    <endEvent id="endevent6" name="End"></endEvent>
    <sequenceFlow id="flow14" name="" sourceRef="scripttask4" targetRef="endevent6"></sequenceFlow>
    <sequenceFlow id="flow15" name="" sourceRef="boundaryerror3" targetRef="scripttask4"></sequenceFlow>
  </process>
Thanks,
Richard
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
It's important to understand that a boundary event cannot be used for Java exceptions.
Boundary events are meant for business exceptions, that have a clear modeling and business meaning.
With a boundary event, you clearly throw an error in a certain path of your process and catch it on the boundary of your subprocess.

If you want to handle Java exceptions, read the section 'handling exceptions' in the user guide: http://activiti.org/userguide/index.html#bpmnJavaServiceTask. If you want to mimic what you actually want, you must catch the Java exception, and continue through a path that throws the error event that is meant to be catched on the subprocess.