AnsweredAssumed Answered

Why NullPointerException, when I use TimerBoundaryEvent?

Question asked by mscai on Mar 28, 2011
Latest reply on Oct 26, 2012 by jbarrez
I just begin to study BPMN and Activiti. I write a prototype to use TimerBoundaryEvent. But when I run the prototype, java.lang.NullPointerException throws. Could anyone help me, please?
Thank you.

The logical  of my prototype is simple. There is one ServiceTask "NormalTask1". If the duration of "NormalTask1" is larger than 10 secondes, do ServiceTask"NT_Timer". 

In my prototype, the execution duration of "NormalTask1" is more than 20 seconds, and I have set "jobExecutorActivate" as true. My activiti engine version is 5.2

Below is the xml of my workflow:
*************
<process id="Timer_Test1" name="">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="NormalTask1" activiti:class="com.sybase.rs.wkpt.process.wfe.HWorld"></serviceTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <boundaryEvent id="boundarytimer1" name="Timer_NT1" cancelActivity="true" attachedToRef="servicetask1">
      <timerEventDefinition>
        <timeDuration>PT10S</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="parallelgateway1"></sequenceFlow>
    <sequenceFlow id="flow10" name="" sourceRef="parallelgateway1" targetRef="endevent1"></sequenceFlow>
    <serviceTask id="servicetask2" name="NT_Timer" activiti:class="com.sybase.rs.wkpt.process.wfe.HWorldTimer"></serviceTask>
    <sequenceFlow id="flow13" name="" sourceRef="boundarytimer1" targetRef="servicetask2"></sequenceFlow>
    <sequenceFlow id="flow14" name="" sourceRef="servicetask2" targetRef="parallelgateway1"></sequenceFlow>
  </process>
*************

When I run the prototype, the below error throws:
*****************
java.lang.NullPointerException at org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler.execute(TimerExecuteNestedActivityJobHandler.java:39)
   at org.activiti.engine.impl.runtime.JobEntity.execute(JobEntity.java:79)
   at org.activiti.engine.impl.runtime.TimerEntity.execute(TimerEntity.java:47)
   at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:54)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:22)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:37)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:36)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
   at java.lang.Thread.run(Thread.java:619)
*****************

I debug the prototype. It doesn't get the ExecutionEntity by executionId at org.activiti.engine.impl.runtime.JobEntity.execute
*************
public void execute(CommandContext commandContext) {

if (executionId != null) {
      execution = runtimeSession.findExecutionById(executionId);
    }

*************

Outcomes