cancel
Showing results for 
Search instead for 
Did you mean: 

Event subprocess with error start event

alemser
Champ in-the-making
Champ in-the-making
Hi,

Please, see attachment and XML below…

When the Review task ends with error, the respective error start event of the event subprocess is not activated.

This message appears in the log:
18/07/2012 14:26:56 org.activiti.engine.impl.bpmn.helper.ErrorPropagation propagateError
INFO: errorEnd throws error event with errorCode '123', but no catching boundary event was defined. Execution will simply be ended (none end event semantics).

Did I miss something?

BPMN
===================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples"
  xmlns:tns="Examples"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
   <error id="err01" errorCode="123" />
   
   <process id="process01" isExecutable="true">
   
      <startEvent id="startEvent01">
         <outgoing>toReview</outgoing>
      </startEvent>
      
      <userTask completionQuantity="1" id="reviewUserTask" implementation="webService"
         isForCompensation="false" name="Review" startQuantity="1">
         <incoming>toReview</incoming>
         <outgoing>toOkGtw</outgoing>
      </userTask>
      
      <exclusiveGateway gatewayDirection="Diverging" id="okGtw" name="ok?">
         <incoming>toOkGtw</incoming>
         <outgoing>toEmptyEnd</outgoing>
         <outgoing>toErrorEnd</outgoing>
      </exclusiveGateway>
      
      <endEvent id="emptyEnd" name="emptyEnd">
         <incoming>toEmptyEnd</incoming>
      </endEvent>
      
      <endEvent id="errorEnd" name="err">
         <incoming>toErrorEnd</incoming>
         <errorEventDefinition errorRef="err01" id="errId" />
      </endEvent>
      
      <sequenceFlow id="toReview"
         name="" sourceRef="startEvent01"
         targetRef="reviewUserTask" />
         
      <sequenceFlow id="toOkGtw"
         name="" sourceRef="reviewUserTask"
         targetRef="okGtw" />
         
      <sequenceFlow id="toEmptyEnd"
         name="ok" sourceRef="okGtw"
         targetRef="emptyEnd">
         
         <conditionExpression id="sid-eff7d8a1-fd2a-4f8f-85a7-d5a694d6c10f"
            xsi:type="tFormalExpression">${condition=='A'}</conditionExpression>
            
      </sequenceFlow>
      
      <sequenceFlow id="toErrorEnd"
         name="not ok" sourceRef="okGtw"
         targetRef="errorEnd">
         
         <conditionExpression id="condExp"
            xsi:type="tFormalExpression">${condition=='R'}</conditionExpression>
            
      </sequenceFlow>
   </process>
   
   <process id="process02" isExecutable="false">
   
      <subProcess completionQuantity="1" id="eventSubProcess" isForCompensation="false"
         name="" startQuantity="1" triggeredByEvent="true">
         
         <startEvent id="errStartEvent" name="err">
            <outgoing>toReport</outgoing>
            <errorEventDefinition errorRef="err01" id="sid-fc567882-11a0-4da4-9787-8a185d893f66" />
         </startEvent>
         
         <userTask completionQuantity="1" id="reportUserTask"
            implementation="webService" isForCompensation="false" name="Report" startQuantity="1">
            <incoming>toReport</incoming>
            <outgoing>toSubEmptyEnd</outgoing>
         </userTask>
         
         <endEvent id="subEmptyEnd" name="">
            <incoming>toSubEmptyEnd</incoming>
         </endEvent>
         
         <sequenceFlow id="toReport"
            name="" sourceRef="errStartEvent"
            targetRef="reportUserTask" />
            
         <sequenceFlow id="toSubEmptyEnd"
            name="" sourceRef="reportUserTask"
            targetRef="subEmptyEnd" />
      </subProcess>
   </process>
</definitions>
============================================================
14 REPLIES 14

frederikherema1
Star Contributor
Star Contributor
You throw an error with error-code "123", have you tried with our the error-code?

alemser
Champ in-the-making
Champ in-the-making
I did try it in different ways.
I  did the same as the user guide example (snippet below). Still not works.



                <error id="myError" errorCode="E1" />

  <endEvent id="errorEnd" name="err">
   <incoming>toErrorEnd</incoming>
   <errorEventDefinition errorRef="myError" id="errId" />
  </endEvent>


  <subProcess completionQuantity="1" id="eventSubProcess" isForCompensation="false"
   name="" startQuantity="1" triggeredByEvent="true">
  
   <startEvent id="errStartEvent" name="err">
    <outgoing>toReport</outgoing>
    <errorEventDefinition errorRef="myError" id="errStartId" />
   </startEvent>


Could you suggest some changes to make it work?

frederikherema1
Star Contributor
Star Contributor
Have you tried this process:
https://svn.codehaus.org/activiti/activiti/trunk/modules/activiti-engine/src/test/resources/org/acti...

This is used to run tests against the engine. There is an "empty" error-event definition:


<errorEventDefinition /> <!– no errorCode: catch any error –>

alemser
Champ in-the-making
Champ in-the-making
Thanks for the link.
I can't run it due some groovy dependencies, but I did some adjusts in my model to make it similar to the example, and got the same error.

I think that might be some problem when, after a gateway, the error comes from an error end event.



  <exclusiveGateway gatewayDirection="Diverging" id="okGtw" name="ok?">
   <incoming>toOkGtw</incoming>
   <outgoing>toEmptyEnd</outgoing>
   [b]<outgoing>toErrorEnd</outgoing>[/b]
  </exclusiveGateway>
 
  <endEvent id="emptyEnd" name="emptyEnd">
   <incoming>toEmptyEnd</incoming>
  </endEvent>
 
  <endEvent id="errorEnd" name="err">
   <incoming>toErrorEnd</incoming>
   [b]<errorEventDefinition errorRef="myError" />[/b]
  </endEvent>

  <subProcess completionQuantity="1" id="eventSubProcess" isForCompensation="false"
   name="" startQuantity="1" triggeredByEvent="true">
  
   <startEvent id="errStartEvent" name="err">
    <outgoing>toReport</outgoing>
    [b]<errorEventDefinition />[/b]
   </startEvent>


frederikherema1
Star Contributor
Star Contributor
Could you please create a failing unit-test, showing this problem (replace all your business-specific service-taks with simple stuff), that would help a lot.

alemser
Champ in-the-making
Champ in-the-making
Below is the definition and the unit test.

XML

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples"
  xmlns:tns="Examples"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
 
<process id="EventSubprocessErrorStartTest" isExecutable="true">

  <startEvent id="startEvent01">
   <outgoing>toReview</outgoing>
  </startEvent>
 
  <userTask id="reviewUserTask" name="Review">
   <incoming>toReview</incoming>
   <outgoing>toOkGtw</outgoing>
  </userTask>
 
  <exclusiveGateway gatewayDirection="Diverging" id="okGtw" name="ok?">
   <incoming>toOkGtw</incoming>
   <outgoing>toEmptyEnd</outgoing>
   <outgoing>toErrorEnd</outgoing>
  </exclusiveGateway>
 
  <endEvent id="emptyEnd" name="emptyEnd">
   <incoming>toEmptyEnd</incoming>
  </endEvent>
 
  <endEvent id="errorEnd" name="err">
   <incoming>toErrorEnd</incoming>
   <errorEventDefinition errorRef="myError" />
  </endEvent>
 
  <sequenceFlow id="toReview" sourceRef="startEvent01" targetRef="reviewUserTask" />
  
  <sequenceFlow id="toOkGtw" sourceRef="reviewUserTask" targetRef="okGtw" />
  
  <sequenceFlow id="toEmptyEnd" sourceRef="okGtw" targetRef="emptyEnd">
  
   <conditionExpression id="exp01" xsi:type="tFormalExpression">${condition=='A'}</conditionExpression>
   
  </sequenceFlow>
 
  <sequenceFlow id="toErrorEnd" sourceRef="okGtw" targetRef="errorEnd">
  
   <conditionExpression id="exp02" xsi:type="tFormalExpression">${condition=='R'}</conditionExpression>
   
  </sequenceFlow>
</process>

<process id="SubprocessErrorStartTest" isExecutable="true">

  <subProcess id="eventSubProcess" triggeredByEvent="true">
  
   <startEvent id="errStartEvent" name="err">
    <outgoing>toReport</outgoing>
    <errorEventDefinition/>
   </startEvent>
  
   <userTask id="reportUserTask" name="Report">
    <incoming>toReport</incoming>
    <outgoing>toSubEmptyEnd</outgoing>
   </userTask>
  
   <endEvent id="subEmptyEnd">
    <incoming>toSubEmptyEnd</incoming>
   </endEvent>
  
   <sequenceFlow id="toReport" sourceRef="errStartEvent"
    targetRef="reportUserTask" />
   
   <sequenceFlow id="toSubEmptyEnd" sourceRef="reportUserTask"
    targetRef="subEmptyEnd" />
  </subProcess>
</process>
</definitions>

Java

@Test
public void testEventSubprocessoErrorStart() {
     Deployment deployment =
         repositoryService.createDeployment()
                     .addClasspathResource("org/activiti/examples/bpmn/subprocess/EventSubprocess.bpmn20.xml")
                     .deploy();
      
      
       ProcessInstance pi = runtimeService.startProcessInstanceByKey("EventSubprocessErrorStartTest");
      
       //should return only one task called 'Review'
       List<Task> tasks = taskService.createTaskQuery()
                                     .processInstanceId(pi.getId()).list();
       assertEquals(1, tasks.size());
       Task reviewTask = tasks.get(0);
       assertEquals("Review", reviewTask.getName());
       //
      
       //creating the variable to evaluate the expression that will lead to an error end event
       Map<String, Object> vars = new HashMap<String, Object>();
       vars.put("condition", "R");
      
       //complete the 'Review' task with the variables
       taskService.complete(reviewTask.getId(), vars);
      
       //should return only one task (event subprocess 'Report' task) bot no one will be returned
       tasks = taskService.createTaskQuery().list();
      
       assertEquals(1, tasks.size());
      
       // Clean up
       repositoryService.deleteDeployment(deployment.getId(), true);
}

frederikherema1
Star Contributor
Star Contributor
I see your problem… You defined the sub-process in a SECOND <process id="…"> tag, which makes it a different process. You should define the sub-process inside the process that throws the error-event, see http://activiti.org/userguide/index.html#bpmnEventSubprocess:

An event subprocess can be added at the process level or at any subprocess level.

If you want cross-process "messaging", use the message-start event end throwing message events.

alemser
Champ in-the-making
Champ in-the-making
I made the change and the problem persists.
Do you have an unit-test with this scenario?

I put the subProcess element below inside the main process and remove the second process from the definition.


<subProcess id="eventSubProcess" triggeredByEvent="true">
<startEvent id="catchError">
                <errorEventDefinition errorRef="myError" />
        </startEvent>
        <sequenceFlow id="flow2" sourceRef="catchError" targetRef="taskAfterErrorCatch" />
        <userTask id="taskAfterErrorCatch" name="Provide additional data" />
</subProcess>

frederikherema1
Star Contributor
Star Contributor
You also forgot to define an "error" definition, in the root <definitions …> element in your XML:


<error id="myError" errorCode="123" />