<!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;">&#160;</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;">&#160;</p><p>&#160;&#160;&#160; (1) in the event listener, we call executeJob:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><p>&#160; public void notify(EventListenerExecution execution)</p><p>&#160; {&#160;&#160; </p><p>&#160;&#160;&#160; String aId&#160;&#160; = execution.getId();</p><p>&#160;&#160;&#160; String aName = execution.getName();&#160;&#160;&#160; </p><p>&#160;&#160;&#160; out("===============================");</p><p>&#160;&#160;&#160; out("timer handler: (timeout) event (" + aId + ").");</p><p>&#160;&#160;&#160; out("===============================");</p></p><div id="_mcePaste">&#160;&#160;&#160; ProcessInstance processInstance = (ProcessInstance) execution.getProcessInstance();&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; ManagementService managementService = EnvironmentImpl.getFromCurrent(ManagementService.class);&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; JobQuery jobQuery = managementService.createJobQuery();&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; JobQuery timerQuery = jobQuery.timers();&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; JobQuery ptQuery = timerQuery.processInstanceId( processInstance.getId() );</div><div id="_mcePaste">&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; List&lt;Job&gt; jobList = ptQuery.list();&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; Job foundJob = null;&#160;&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; for(int ii=0 ; ii &lt; jobList.size(); ii++)</div><div id="_mcePaste">&#160;&#160;&#160; {</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; Job jbpmJob = jobList.get(ii);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; Execution jobExcu = jbpmJob.getExecution();&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; String bId&#160;&#160; = jobExcu.getId();</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; String bName = jobExcu.getName();&#160;&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; if( ! bId.equals(aId) || ! bName.equals(aName) )</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160;&#160;&#160; continue;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; foundJob = jbpmJob;</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; break;</div><div id="_mcePaste">&#160;&#160;&#160; }</div><div id="_mcePaste">&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; if( foundJob == null )</div><div id="_mcePaste">&#160;&#160;&#160; {</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; err("cannot find a matched timer object in external db: (execId: " + aId + "), (name: " + aName + ").");</div><div id="_mcePaste">&#160;&#160;&#160;&#160;&#160; return;</div><div id="_mcePaste">&#160;&#160;&#160; }</div><div id="_mcePaste">&#160;&#160;&#160; out("found a matched timer object in external db: (execId: " + aId + "), (name: " + aName + "), (timerId: " + foundJob.getId() + ").");&#160;&#160;&#160;&#160;&#160;&#160; </div><div id="_mcePaste">&#160;&#160;&#160; managementService.executeJob( foundJob.getId() );&#160;&#160; </div><div>&#160; }</div><div> </div><div>&#160; (2) in the process definition, we linked it with the timer:</div><div> </div><div>&#160;&#160;&#160; &lt;state g="222,123,147,40" name="generate-file"&gt;</div><div>&#160;&#160;&#160;&#160;&#160; &lt;on event="timeout"&gt;</div><div>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;timer duedate="10 seconds"/&gt;</div><div><span> </span>&#160;&#160;&#160;&#160;&#160; &lt;event-listener class="basicfive.TestTimerHandler"&gt;</div><div>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name="msg"&gt;&lt;string value="entered the (generate-file) state node."/&gt;&lt;/field&gt;</div><div>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/event-listener&gt;<span> </span>&#160; </div><div>&#160;&#160;&#160;&#160;&#160; &lt;/on&gt; </div><div>&#160;&#160;&#160;&#160;&#160; &lt;on event="start"&gt;</div><div><span> </span>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;event-listener class="basicfive.TestJobMakeRequestHandler"&gt;</div><div>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name="msg"&gt;&lt;string value="entered the (generate-file) state node."/&gt;&lt;/field&gt;</div><div>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/event-listener&gt;<span> </span>&#160; </div><div>&#160;&#160;&#160;&#160;&#160; &lt;/on&gt; </div><div>&#160;&#160;&#160;&#160;&#160; &lt;transition g="-71,-15" name="timeout" to="remove-file"&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </div><div>&#160;&#160;&#160;&#160;&#160; &lt;/transition&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </div><div>&#160;&#160; &lt;/state&gt;</div><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160; (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;">&#160;</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&#160;&#160;&#160;&#160;&#160;&#160; | [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;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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>