2 Replies Latest reply on Jul 29, 2010 12:32 PM by Tun Mang

    in jbpm 4.3, timer's event listener throws exception on ExecuteEventListener.java:68.

    Tun Mang Novice

      Hi there,

       

      Follow the example described in "jbpm-4.3/doc/devguide/html_single/index.html#timer", the following is what we have done:

       

          (1) in the event listener, we call executeJob:

       

        public void notify(EventListenerExecution execution)

        {  

          String aId   = execution.getId();

          String aName = execution.getName();   

          out("===============================");

          out("timer handler: (timeout) event (" + aId + ").");

          out("===============================");

          ProcessInstance processInstance = (ProcessInstance) execution.getProcessInstance();   
          ManagementService managementService = EnvironmentImpl.getFromCurrent(ManagementService.class);   
          JobQuery jobQuery = managementService.createJobQuery();   
          JobQuery timerQuery = jobQuery.timers();   
          JobQuery ptQuery = timerQuery.processInstanceId( processInstance.getId() );
         
          List<Job> jobList = ptQuery.list();   
          Job foundJob = null;     
          for(int ii=0 ; ii < jobList.size(); ii++)
          {
            Job jbpmJob = jobList.get(ii);         
            Execution jobExcu = jbpmJob.getExecution();    
            String bId   = jobExcu.getId();
            String bName = jobExcu.getName();     
            if( ! bId.equals(aId) || ! bName.equals(aName) )
              continue;          
            foundJob = jbpmJob;
            break;
          }
         
          if( foundJob == null )
          {
            err("cannot find a matched timer object in external db: (execId: " + aId + "), (name: " + aName + ").");
            return;
          }
          out("found a matched timer object in external db: (execId: " + aId + "), (name: " + aName + "), (timerId: " + foundJob.getId() + ").");      
          managementService.executeJob( foundJob.getId() );  
        }
        (2) in the process definition, we linked it with the timer:
          <state g="222,123,147,40" name="generate-file">
            <on event="timeout">
              <timer duedate="10 seconds"/>
            <event-listener class="basicfive.TestTimerHandler">
                <field name="msg"><string value="entered the (generate-file) state node."/></field>
              </event-listener>  
            </on>
            <on event="start">
              <event-listener class="basicfive.TestJobMakeRequestHandler">
                <field name="msg"><string value="entered the (generate-file) state node."/></field>
              </event-listener>  
            </on>
            <transition g="-71,-15" name="timeout" to="remove-file">       
            </transition>          
         </state>

       

        (3) When start the process instance, and after it reaches the handler, it always throws the following exeptions:

       

      10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) ===============================

      10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) timer handler: (timeout) event (test_Timer_1.680001.generate-file).

      10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) ===============================

      10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) found a matched timer object in external db: (execId: test_Timer_1.680001.generate-file), (name: generate-file), (timerId: 680004).

      10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) leaving event fired for timer object in external db: (id: test_Timer_1.680001.generate-file), (name: generate-file).

      ### EXCEPTION ###########################################

      17:01:17,161 SEV       | [ExecuteJobCmd] exception while executing 'timer[680004|2010-07-28 17:01:15,000|timeout]'

      java.lang.NullPointerException

      at org.jbpm.pvm.internal.model.op.ExecuteEventListener.perform(ExecuteEventListener.java:68)

      at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:678)

      at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:638)

      at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:585)

      at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:575)

      ......

       

       

      How do we resolve this problem ? Thanks a lot for your help in advance.

        • 1. Re: in jbpm 4.3, timer's event listener throws exception on ExecuteEventListener.java:68.
          HuiSheng Xu Master

          Hi Tun,

           

          I don't know why you want to executeJob() in EventListener.  Could you tell me the reason for doing that?  Thank you very much.

          • 2. Re: in jbpm 4.3, timer's event listener throws exception on ExecuteEventListener.java:68.
            Tun Mang Novice

            Hi HuiSheng:

             

            Because the process never reached the next node "remove-file", that is why executeJob() was added to the event handler. (By the way, during the process the job entry has been automatically removed from jbpm4_job table though.)

             

            In the same process, if change the timer's node "generate-file" to the following, then it works (i.e. it reached the "remove-file" node):

             

               <state g="222,123,147,40" name="generate-file">    
                  <on event="start">
                   <event-listener>
                      <field name="msg"><string value="entered the (generate-file) state node."/></field>
                    </event-listener>      
                  </on>
                  <transition g="-71,-15" name="timeout" to="remove-file">
                    <timer duedate="10 seconds"/> 
                  </transition>          
               </state>

             

            Why it does not go to the next node if use the "timeout" event handler and how to make it work ?

             

            Thanks a lot for your help.