<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
in jbpm 4.3, timer's event listener throws exception on ExecuteEventListener.java:68.
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/tunmang">Tun Mang</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/554894#554894">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi there,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Follow the example described in "jbpm-4.3/doc/devguide/html_single/index.html#timer", the following is what we have done:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    (1) in the event listener, we call executeJob:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><p>  public void notify(EventListenerExecution execution)</p><p>  {   </p><p>    String aId   = execution.getId();</p><p>    String aName = execution.getName();    </p><p>    out("===============================");</p><p>    out("timer handler: (timeout) event (" + aId + ").");</p><p>    out("===============================");</p></p><div id="_mcePaste">    ProcessInstance processInstance = (ProcessInstance) execution.getProcessInstance();    </div><div id="_mcePaste">    ManagementService managementService = EnvironmentImpl.getFromCurrent(ManagementService.class);    </div><div id="_mcePaste">    JobQuery jobQuery = managementService.createJobQuery();    </div><div id="_mcePaste">    JobQuery timerQuery = jobQuery.timers();    </div><div id="_mcePaste">    JobQuery ptQuery = timerQuery.processInstanceId( processInstance.getId() );</div><div id="_mcePaste">    </div><div id="_mcePaste">    List<Job> jobList = ptQuery.list();    </div><div id="_mcePaste">    Job foundJob = null;      </div><div id="_mcePaste">    for(int ii=0 ; ii < jobList.size(); ii++)</div><div id="_mcePaste">    {</div><div id="_mcePaste">      Job jbpmJob = jobList.get(ii);          </div><div id="_mcePaste">      Execution jobExcu = jbpmJob.getExecution();     </div><div id="_mcePaste">      String bId   = jobExcu.getId();</div><div id="_mcePaste">      String bName = jobExcu.getName();      </div><div id="_mcePaste">      if( ! bId.equals(aId) || ! bName.equals(aName) )</div><div id="_mcePaste">        continue;           </div><div id="_mcePaste">      foundJob = jbpmJob;</div><div id="_mcePaste">      break;</div><div id="_mcePaste">    }</div><div id="_mcePaste">    </div><div id="_mcePaste">    if( foundJob == null )</div><div id="_mcePaste">    {</div><div id="_mcePaste">      err("cannot find a matched timer object in external db: (execId: " + aId + "), (name: " + aName + ").");</div><div id="_mcePaste">      return;</div><div id="_mcePaste">    }</div><div id="_mcePaste">    out("found a matched timer object in external db: (execId: " + aId + "), (name: " + aName + "), (timerId: " + foundJob.getId() + ").");       </div><div id="_mcePaste">    managementService.executeJob( foundJob.getId() );   </div><div>  }</div><div> </div><div>  (2) in the process definition, we linked it with the timer:</div><div> </div><div>    <state g="222,123,147,40" name="generate-file"></div><div>      <on event="timeout"></div><div>        <timer duedate="10 seconds"/></div><div><span> </span>      <event-listener class="basicfive.TestTimerHandler"></div><div>          <field name="msg"><string value="entered the (generate-file) state node."/></field></div><div>        </event-listener><span> </span>  </div><div>      </on> </div><div>      <on event="start"></div><div><span> </span>        <event-listener class="basicfive.TestJobMakeRequestHandler"></div><div>          <field name="msg"><string value="entered the (generate-file) state node."/></field></div><div>        </event-listener><span> </span>  </div><div>      </on> </div><div>      <transition g="-71,-15" name="timeout" to="remove-file">        </div><div>      </transition>           </div><div>   </state></div><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>  (3) When start the process instance, and after it reaches the handler, it always throws the following exeptions:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><p>10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) ===============================</p><p>10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) timer handler: (timeout) event (test_Timer_1.680001.generate-file).</p><p>10-07-28/17:01:17 DEBUG [basicfive.TestTimerHandler]: (AP) ===============================</p><p>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).</p><p>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).</p><p>### EXCEPTION ###########################################</p><p>17:01:17,161 SEV       | [ExecuteJobCmd] exception while executing 'timer[680004|2010-07-28 17:01:15,000|timeout]'</p><p>java.lang.NullPointerException</p><p><span> </span>at org.jbpm.pvm.internal.model.op.ExecuteEventListener.perform(ExecuteEventListener.java:68)</p><p><span> </span>at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:678)</p><p><span> </span>at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:638)</p><p><span> </span>at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:585)</p><p><span> </span>at org.jbpm.pvm.internal.model.ExecutionImpl.fire(ExecutionImpl.java:575)</p></p><p>......</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>How do we resolve this problem ? Thanks a lot for your help in advance.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/554894#554894">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>