10-11-2012 09:55 AM
throw new BpmnError("Hulk smash");
I take a look in this code at AbstractEventAtomicOperation:
public void execute(InterpretableExecution execution) {
ScopeImpl scope = getScope(execution);
List<ExecutionListener> exectionListeners = scope.getExecutionListeners(getEventName());
int executionListenerIndex = execution.getExecutionListenerIndex();
(…)
the problem is this var scope, this is null when haven't a boundaryEvent to catch exceptions…
11/10/2012 10:27:33 org.activiti.engine.impl.bpmn.helper.ErrorPropagation propagateError
INFO: testeScript throws error event with errorCode 'Hulk smash', but no catching boundary event was defined. Execution will simply be ended (none end event semantics).
11/10/2012 10:29:51 org.activiti.engine.impl.interceptor.CommandContext close
GRAVE: Error while closing command context
java.lang.NullPointerException
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:42)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:80)
(…)
If "Execution will simply be ended (none end event semantics)." , why NullPointerException?
<scriptTask id="testeScript" name="Teste script" scriptFormat="groovy">
<script><![CDATA[
osama = "Osama";
throw new BpmnError("Hulk smash");
osama2="Osama2222";
]]></script>
</scriptTask>
<boundaryEvent id="catchErrorGeneric" attachedToRef="testeScript" cancelActivity="true">
<errorEventDefinition id="genericError" />
</boundaryEvent>
<sequenceFlow sourceRef="catchErrorGeneric" targetRef="printaGeneric" />
<scriptTask id="printaGeneric" name="Generic script" scriptFormat="groovy">
<script><![CDATA[
println("generic error/exception man!");
]]></script>
</scriptTask>
<sequenceFlow sourceRef="printaGeneric" targetRef="theEnd" />
10-11-2012 10:15 AM
10-11-2012 10:24 AM
Can you poor this into an executable unit-test, so we can see the exact process and reproduce this issue? See the sticky in the forum on how to do this.Hi, I can do this test, this posted code protect this NPE:
Judging from the process extract , I don't see anything who wrong that should cause the NPE. The execution should indeed just simply be ended.
Also, be careful with mentioning "osama" in your posts, don't want the FBI to flag activiti as a terrorist engine
<boundaryEvent id="catchErrorGeneric" attachedToRef="testeScript" cancelActivity="true">
<errorEventDefinition id="genericError" />
</boundaryEvent>
but without this boundaryEvent throw a NPE, because, haven't a catch boundaryEvent.10-11-2012 10:31 AM
Also, be careful with mentioning "osama" in your posts, don't want the FBI to flag activiti as a terrorist engineThank's, I will take careful , terrorist engine omg! euhuaeh
10-15-2012 02:36 PM
<boundaryEvent id="catchErrorGeneric" attachedToRef="testScript" cancelActivity="true">
<errorEventDefinition id="genericError" />
</boundaryEvent>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.1</version>
</dependency>
@Deployment(resources = {"org/activiti/test/my-process.bpmn20.xml"})
by this: @Deployment(resources = {"org/activiti/test/catchingException.bpmn20.xml"})
in org.activiti.MyUnitTest.java
<?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" xmlnsmgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlnsmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="error NullPointerException (bug ?) - nandoztx">
<error id="errorOne" name="testExceptionOne" errorCode="exceptionOne" />
<error id="errorTwo" name="testExceptionTwo" errorCode="exceptionTwo" />
<process id="catchingException" name="catch any exception - nandoztx">
<startEvent id="start" name="Start" />
<sequenceFlow sourceRef="start" targetRef="firstScript" />
<!– test if this 'var1' var is serialized, but is not –>
<scriptTask id="firstScript" name="Teste script"
scriptFormat="groovy">
<script><![CDATA[
var1 = "VAR1!";
]]></script>
</scriptTask>
<sequenceFlow sourceRef="firstScript" targetRef="testScript" />
<scriptTask id="testScript" name="Teste script"
scriptFormat="groovy">
<script><![CDATA[
//activiti loves BpmnError
import org.activiti.engine.delegate.BpmnError;
var2 = "VAR2";
throw new BpmnError("bananaException"); // will throw NPE (if not have a generic catch exception, like this "catchErrorGeneric")
//throw new BpmnError("exceptionTwo"); //will be catched
var3="VAR3";
]]></script>
</scriptTask>
<sequenceFlow sourceRef="testScript" targetRef="theEnd" />
<!– flag cancelActivity is used to signal to process terminate when have task not finished yet (with erros) –>
<boundaryEvent id="catchErrorOne" attachedToRef="testScript" cancelActivity="true">
<errorEventDefinition id="one" errorRef="errorOne" />
</boundaryEvent>
<boundaryEvent id="catchErrorTwo" attachedToRef="testScript" cancelActivity="true">
<errorEventDefinition id="two" errorRef="errorTwo" />
</boundaryEvent>
<!– if enable this generic catch BpmnError, no have NPE and will print "generic error/exception man!" –>
<!– <boundaryEvent id="catchErrorGeneric" attachedToRef="testScript" cancelActivity="true">
<errorEventDefinition id="genericError" />
</boundaryEvent> –>
<!– if event has not directed, so process will be 'flying' in the DB without user to get him ? –>
<sequenceFlow sourceRef="catchErrorOne" targetRef="printOne" />
<sequenceFlow sourceRef="catchErrorTwo" targetRef="printTwo" />
<!– uncomment this code below if you has uncomment that "catchErrorGeneric", this is a sequence flow –>
<!– <sequenceFlow sourceRef="catchErrorGeneric" targetRef="printGeneric" /> –>
<scriptTask id="printGeneric" name="Generic script" scriptFormat="groovy">
<script><![CDATA[ println("generic error/exception man!");
]]></script>
</scriptTask>
<scriptTask id="printOne" name="Script error one" scriptFormat="groovy">
<script><![CDATA[ println("ERROR ONE CATCHED!!!");
]]></script>
</scriptTask>
<scriptTask id="printTwo" name="Script error two" scriptFormat="groovy">
<script><![CDATA[ println("ERROR TWO CATCHED!!!");
]]></script>
</scriptTask>
<sequenceFlow sourceRef="printOne" targetRef="theEnd" />
<sequenceFlow sourceRef="printTwo" targetRef="theEnd" />
<sequenceFlow sourceRef="printGeneric" targetRef="theEnd" />
<endEvent id="theEnd"/>
</process>
</definitions>
10-16-2012 05:53 AM
10-16-2012 09:19 AM
10-16-2012 02:09 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.