AnsweredAssumed Answered

Exception when multi-instance service task itself inside a loop

Question asked by yevgenyl on Aug 2, 2018
Latest reply on Aug 6, 2018 by yevgenyl

I have the below process. In my process there is a multi-instance service task that itself is a part of a loop.

 

 

The issue is that I'm getting the below exception after the process is finished.

If I'll make Service Task 3 not to be multi-instanced or if Service Task 3 will not be part of the bigger loop, then I'll not get the exception, so the exception is happening specifically for the case I mentioned. 

 

org.activiti.engine.impl.pvm.PvmException: already taking a transition
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:453) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:438) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior.leave(SequentialMultiInstanceBehavior.java:75) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.execute(MultiInstanceActivityBehavior.java:98) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior.execute(SequentialMultiInstanceBehavior.java:90) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60) ~[activiti-engine-5.22.0.jar:5.22.0]
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97) ~[activiti-engine-5.22.0.jar:5.22.0]

 

The xml is:

 

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<serviceTask id="servicetask1" name="Service Task 1" activiti:delegateExpression="${serviceTask1}"></serviceTask>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
<serviceTask id="servicetask2" name="Service Task 2" activiti:delegateExpression="${serviceTask2}"></serviceTask>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow3" name="list not empty" sourceRef="exclusivegateway1" targetRef="servicetask2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!myList.isEmpty()}]]></conditionExpression>
</sequenceFlow>
<serviceTask id="servicetask3" name="Service Task 3" activiti:delegateExpression="${serviceTask3}">
<multiInstanceLoopCharacteristics isSequential="true" activiti:collection="myList" activiti:elementVariable="element"></multiInstanceLoopCharacteristics>
</serviceTask>
<sequenceFlow id="flow5" sourceRef="servicetask2" targetRef="servicetask3"></sequenceFlow>
<sequenceFlow id="flow6" name="list empty" sourceRef="exclusivegateway1" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${myList.isEmpty()}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
<bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="180.0" y="250.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="443.0" y="360.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
<omgdc:Bounds height="55.0" width="105.0" x="280.0" y="240.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
<omgdc:Bounds height="55.0" width="105.0" x="576.0" y="240.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="440.0" y="247.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
<omgdc:Bounds height="55.0" width="105.0" x="576.0" y="130.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="215.0" y="267.0"></omgdi:waypoint>
<omgdi:waypoint x="280.0" y="267.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="385.0" y="267.0"></omgdi:waypoint>
<omgdi:waypoint x="440.0" y="267.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="480.0" y="267.0"></omgdi:waypoint>
<omgdi:waypoint x="576.0" y="267.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="489.0" y="267.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="628.0" y="240.0"></omgdi:waypoint>
<omgdi:waypoint x="628.0" y="185.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="460.0" y="287.0"></omgdi:waypoint>
<omgdi:waypoint x="460.0" y="360.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="100.0" x="470.0" y="309.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

 

How to solve it please?

Outcomes