cancel
Showing results for 
Search instead for 
Did you mean: 

How can I forward catched exception?

al_lv
Champ in-the-making
Champ in-the-making
Hallo all,

this is my process definition:
<?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: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="siebel" name="siebel">
    <startEvent id="startevent3" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="SiebelTask" activiti:class="de.ec4u.c4.workflowserver.servicetasks.SiebelTask"></serviceTask>
    <endEvent id="endevent3" name="End"></endEvent>
    <sequenceFlow id="flow2" name="" sourceRef="startevent3" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="endevent3"></sequenceFlow>
   <boundaryEvent attachedToRef="servicetask1" cancelActivity="true" id="boundaryerror1" name="" parallelMultiple="false">        
         <errorEventDefinition/>
    </boundaryEvent>
   <sequenceFlow id="flow4" name="to Service Task" sourceRef="boundaryerror1" targetRef="servicetask2"></sequenceFlow>
   <serviceTask id="servicetask2" name="WriteToFile" activiti:class="de.ec4u.c4.workflowserver.servicetasks.WriteToFile"></serviceTask>
   <endEvent id="endevent4" name="End"></endEvent>
   <sequenceFlow id="flow5" name="" sourceRef="servicetask2" targetRef="endevent4"></sequenceFlow>
</process>
</definitions>

the diagramm:
[attachment=0]archive_document_v2.png[/attachment].

I want to catch all exceptions that can be throwen during SibelTask and write the stack trace into the file.
Is it possible with boundary error event?
If yes, how can I forward with boundary error event catched error or exception to the next Java Service task?

Thanks

Alexej
3 REPLIES 3

al_lv
Champ in-the-making
Champ in-the-making
I think I found what I need:

transition = execution.getActivity().findOutgoingTransition("no-exception");

It isn't perfect, but at least I am able ty change a path if exception was thrown.

The problem is: I can't call getActivity() on DelegateExecution obejct.

Why it isn't available any more? How can I handle exceptions with Activity v5.3?

Thanks

Alexej

al_lv
Champ in-the-making
Champ in-the-making
Sorry for my inattention,
I found the error.

The Service Task should implemet ActivityBehavior instead of JavaDelegation
public class SiebelTask implements ActivityBehavior{

}


and execute(XX) with ActivityExecution instead of DeleagteExecution
public void execute(ActivityExecution execution) throws Exception {

}

The problem ist solved.

jbarrez
Star Contributor
Star Contributor
Thanks for posting your solution! Your analysis is indeed correct.