AnsweredAssumed Answered

Exception in SingnalEvent

Question asked by rvashishth on Jun 24, 2014
Latest reply on Jun 25, 2014 by rvashishth
Hi,

I am getting following exception while using signal event.


Jun 24, 2014 3:22:26 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
java.lang.NullPointerException
   at org.activiti.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior.leave(ParallelMultiInstanceBehavior.java:104)
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:49)



<signal id="approvalsignal" name="approvalsignal"></signal>
  <process id="EventLoopProcess" name="My process" isExecutable="true" xmlns:drools="http://www.jboss.org/drools" drools:version="1" drools:packageName="defaultPackage" drools:adHoc="false">
    <startEvent id="startevent1" name="Start"></startEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>System.out.println("script task 1");</script>
    </scriptTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent2" name="Start"></startEvent>
      <serviceTask id="servicetask2" name="Service Task" activiti:class="com.jato.activititest.HelloServiceTaskEvent">
        <multiInstanceLoopCharacteristics isSequential="false">
          <loopCardinality>3</loopCardinality>
        </multiInstanceLoopCharacteristics>
      </serviceTask>
      <sequenceFlow id="flow3" sourceRef="startevent2" targetRef="servicetask2"></sequenceFlow>
      <endEvent id="endevent3" name="End"></endEvent>
      <sequenceFlow id="flow4" sourceRef="servicetask2" targetRef="endevent3"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow5" sourceRef="scripttask1" targetRef="subprocess1"></sequenceFlow>
    <scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>System.out.println("after subprocess");</script>
    </scriptTask>
    <sequenceFlow id="flow6" sourceRef="subprocess1" targetRef="scripttask2"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="subprocess1" cancelActivity="true">
      <signalEventDefinition signalRef="approvalsignal"></signalEventDefinition>
    </boundaryEvent>
    <scriptTask id="scripttask3" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>System.out.println("interrupted");</script>
    </scriptTask>
    <sequenceFlow id="flow7" sourceRef="boundarysignal1" targetRef="scripttask3"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="scripttask3" targetRef="endevent1"></sequenceFlow>
  </process>


following is the service class that is creating signal event


@Override
   public void execute(DelegateExecution execution) throws Exception {
      System.out.println("executing HelloServiceTaskEvent");
      execution.setVariable("user1approved", "true");
      RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
      if(!userApproved()){
         System.out.println("creating signal");
         runtimeService.signalEventReceived("approvalsignal");
      }
      
   }


I have tried by changing multiinstance behavior to sequential as well and runtimeService.signalEventReceivedAsyc, it looks like i have missed something in signal event implementations.
My requirement is to run the service task in loop and exit that at specific condition.


Thanks,
Rahul Vashishth

Outcomes