cancel
Showing results for 
Search instead for 
Did you mean: 

exlusiveGateway default error

clever
Champ in-the-making
Champ in-the-making
Hi I'm fairly new to activity, i have a situation where I want to do the following:
if a then taskA
if b then taskB
else throw java RuntimeException

here's what I got:


….
<sequenceFlow id="flow1" sourceRef="start" targetRef="decision" />
<exclusiveGateway id="decision" name="pick task" default="goToThrowException" />
<sequenceFlow id="flow2" sourceRef="decision" targetRef="taskA" >
<conditionExpression>${activitiWorkflowService.evaluate(execution, "isTaskA")}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow3" sourceRef="decision" targetRef="taskB" >
<conditionExpression>${activitiWorkflowService.evaluate(execution, "isTaskB")}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="goToThrowException" sourceRef="decision" targetRef="throwException"/>
<sequenceFlow id="flow4" sourceRef="throwException" targetRef="decisionEnd"/>
<serviceTask id="throwException" name="Throw error no task defined" activiti:class="com.path.activiti.ActivitiServiceTask" />
<exclusiveGateway id="decisionEnd" name="decision task END"/>
<sequenceFlow id="flow5" sourceRef="decisionEnd" targetRef="end" />
….


Sorry if some of the steps are redundant but I'm new to this and i'm unsure if there'a better way to do it. Now, how can i get this xml to call java code that will throw my exeption as follows or if activiti has a better way to do it:


public void handleUnsupportedSpecialDoc() throws Exception{
    throw new RuntimeException("unsupport task by workflow");
}


THanks,
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
In case you have 2 outgoing flows on an exclusive gateway which BOTH have an expression, the error will be thrown by default, when non of the 2 expression resolve to true. Activiti will throw an exception when none of the conditions resolve to true:


//No sequence flow could be found, not even a default one
        throw new ActivitiException("No outgoing sequence flow of the exclusive gateway '"
              + execution.getActivity().getId() + "' could be selected for continuing the process");

Also, make sure NONE of the flows is marked as "default"…