AnsweredAssumed Answered

activiti:delegateExpression: BpmnError not caught

Question asked by workflowuser2 on Jul 20, 2012
Latest reply on Sep 11, 2012 by bernd.ruecker

I have a subprocess and a boundary error event on the subprocess scope. Now, in the subprocess, I have service tasks with activiti:delegateExpression. In these java delegates, if I throw BpmnError, it is never caught and processed.

The same process works if I use java delegates (activiti:class="java.delegate.class") instead of activiti:delegateExpression.
In the regular java delegate case, I observed, org.activiti.engine.impl.bpmn.helper.ClassDelegate wraps ServiceTaskJavaDelegateActivityBehavior and process BpmnError:
try {
    } catch (BpmnError error) {
      ErrorPropagation.propagateError(error, execution);

However, ServiceTaskDelegateExpressionActivityBehavior call does not go through ClassDelegate and therefore does not handle BpmnError.

I hope the above information is enough to understand the bug. Since I am using OSGi, it is difficult to attach unit test.
Please let me know if I am missing something.

Process xml:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="" xmlns:xsi="" xmlns:activiti="" xmlns:bpmndi="" xmlns:omgdc="" xmlns:omgdi="" typeLanguage="" expressionLanguage="" targetNamespace="">
  <process id="applyProfile" name="Apply Profile">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="mainProcess"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="mainProcess" targetRef="endevent1"></sequenceFlow>
    <subProcess id="mainProcess">
       <startEvent id="subProcessStart" />
       <endEvent id="subProcessEnd" />
       <serviceTask id="step1" name="step1WithError" activiti:delegateExpression="${main1Delegate}"></serviceTask>
       <serviceTask id="step2" name="step2" activiti:class="com.acme.delegates.Main2Delegate"></serviceTask>
       <sequenceFlow id="flow11" sourceRef="subProcessStart" targetRef="step1" />
       <sequenceFlow id="flow12" sourceRef="step1" targetRef="step2" />
       <sequenceFlow id="flow13" sourceRef="ApplyProfile" targetRef="subProcessEnd" />
   <serviceTask id="errorTask" name="Global error handling" activiti:class="com.acme.delegates.Main1Delegate"></serviceTask>
    <endEvent id="errorEnd" />
    <sequenceFlow id="flow_error1" sourceRef="errorEvent" targetRef="errorTask" />
    <sequenceFlow id="flow_error2" sourceRef="errorTask" targetRef="errorEnd" />
   <boundaryEvent id="errorEvent" attachedToRef="mainProcess">
</serviceTask> –>

main1Delegate is an OSGi service (also JavaDelegate). Now, in this java delegate, if I throw BpmnError, it is never caught and error flow is not activated.