<!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">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;">
    timer 4.3 error
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/lamj1">Jas Lam</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/535918#535918">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I modified the org.jbpm.examples.eventlistener jUnit test case slightly to introduce a timer as follow: the red code is the newly insert timer.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&lt;?xml version=<font color="red">"1.0"</font> encoding=<font color="red">"UTF-8"</font>?&gt;
&#160;
&lt;process name=<font color="red">"EventListener"</font> xmlns=<font color="red">"http://jbpm.org/4.2/jpdl"</font>&gt;
&#160; &lt;on event=<font color="red">"start"</font>&gt;
&#160;&#160;&#160; &lt;event-listener&gt;
&#160;&#160;&#160;&#160;&#160; &lt;field name=<font color="red">"msg"</font>&gt;&lt;string value=<font color="red">"start on process definition"</font>/&gt;&lt;/field&gt;
&#160;&#160;&#160; &lt;/event-listener&gt;
&#160; &lt;/on&gt;
&#160;
&#160; &lt;start g=<font color="red">"17,19,48,48"</font>&gt;
&#160;&#160;&#160; &lt;transition to=<font color="red">"wait"</font>/&gt;
&#160; &lt;/start&gt;
&#160;
&#160; &lt;state name=<font color="red">"wait"</font> g=<font color="red">"96,16,104,52"</font>&gt;
&#160; &lt;on event=<font color="red">"start"</font>&gt;
&#160;&#160; &lt;event-listener&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name=<font color="red">"msg"</font>&gt;&lt;string value=<font color="red">"start on activity wait"</font>/&gt;&lt;/field&gt;
&#160;&#160; &lt;/event-listener&gt;
&#160; &lt;/on&gt;
 
&#160; &lt;on event=<font color="red">"NotifyRCP"</font>&gt;
&#160;&#160;&#160;&#160;&#160; &lt;timer duedate=<font color="red">"5 seconds"</font>/&gt;
&#160;&#160;&#160;&#160;&#160;&#160; &lt;event-listener&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name=<font color="red">"msg"</font>&gt;&lt;string value=<font color="red">"NotifyRCP"</font>/&gt;&lt;/field&gt;&#160;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160;&#160;&#160;&#160; &lt;/event-listener&gt;&#160;&#160;&#160;&#160;&#160; 
&#160;&#160;&#160; &lt;/on&gt; &#160;&#160;&#160;&#160; 
&#160;
&#160;&#160;&#160; &lt;on event=<font color="red">"end"</font>&gt;
&#160;&#160;&#160;&#160;&#160; &lt;event-listener&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name=<font color="red">"msg"</font>&gt;&lt;string value=<font color="red">"end on activity wait"</font>/&gt;&lt;/field&gt;
&#160;&#160;&#160;&#160;&#160; &lt;/event-listener&gt;
&#160;&#160;&#160; &lt;/on&gt;
&#160;
&#160;&#160;&#160; &lt;transition to=<font color="red">"park"</font>&gt;
&#160;&#160;&#160;&#160;&#160; &lt;event-listener&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;field name=<font color="red">"msg"</font>&gt;&lt;string value=<font color="red">"take transition"</font>/&gt;&lt;/field&gt;
&#160;&#160;&#160;&#160;&#160; &lt;/event-listener&gt;
&#160;&#160;&#160; &lt;/transition&gt;
&#160; &lt;/state&gt;
 
&#160; &lt;state name=<font color="red">"park"</font> g=<font color="red">"231,19,80,52"</font>/&gt;
&#160;
&lt;/process&gt;
&#160;
 
&#160;
&#160;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In the test case i just add an additional text to the expectedLogs and a sleep</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> testEventListener() <font color="navy">{</font>
&#160;&#160;&#160; ProcessInstance processInstance = executionService.startProcessInstanceByKey(<font color="red">"EventListener"</font>);
&#160;&#160;&#160; List&lt;String&gt; expectedLogs = <font color="navy"><b>new</b></font> ArrayList&lt;String&gt;();
&#160;&#160;&#160; expectedLogs.add(<font color="red">"start on process definition"</font>);
&#160;&#160;&#160; expectedLogs.add(<font color="red">"start on activity wait"</font>);
&#160;&#160;&#160; expectedLogs.add(<font color="red">"NotifyRCP"</font>);
&#160;&#160;&#160; <font color="navy"><b>try</b></font><font color="navy">{</font> Thread.sleep(6000); <font color="navy">}</font> <font color="navy"><b>catch</b></font>(Exception e)<font color="navy">{</font><font color="navy">}</font>
&#160;
&#160;&#160;&#160; List&lt;String&gt; logs = (List&lt;String&gt;) executionService.getVariable(processInstance.getId(), <font color="red">"logs"</font>);
&#160;&#160;&#160; 
&#160;&#160;&#160; assertEquals(expectedLogs, logs);
&#160;&#160;&#160; 
&#160;&#160;&#160; Execution execution = processInstance.findActiveExecutionIn(<font color="red">"wait"</font>);&#160;&#160;&#160; 
&#160;&#160;&#160; executionService.signalExecutionById(execution.getId());
&#160;&#160;&#160; 
&#160;&#160;&#160; logs = (List&lt;String&gt;) executionService.getVariable(processInstance.getId(), <font color="red">"logs"</font>);
&#160;&#160;&#160; expectedLogs.add(<font color="red">"end on activity wait"</font>);
&#160;&#160;&#160; expectedLogs.add(<font color="red">"take transition"</font>);
&#160;&#160;&#160; 
&#160;&#160;&#160; assertEquals(expectedLogs, logs);
&#160; <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When I run this code the first time, it always work!!!! BUT after that I kept failing when the timer triggered!!!&#160; with the following error trace. Could some one confirm this? i tried this on two separate machine and getting the same behavior. Full source code is attached. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">15:09:12,216 FIN | [ExecuteActivity] execution[EventListener.50007.wait] executes activity(wait)
[start on process definition, start on activity wait]
15:09:12,232 FIN | [HibernateSessionResource] ----- committing hibernate tx 23511316 -------------------------------------------------------
15:09:12,240 FIN&#160;&#160; | [HibernateSessionResource] ----- beginning hibernate tx 31798998 --------------------------------------------------------
15:09:12,241 FIN&#160;&#160; | [HibernateSessionResource] ----- committing hibernate tx 32102833 -------------------------------------------------------
15:09:12,242 FIN&#160;&#160; | [HibernateSessionResource] ----- beginning hibernate tx 22677439 --------------------------------------------------------
15:09:12,251 FIN&#160;&#160; | [HibernateSessionResource] ----- committing hibernate tx 32700170 -------------------------------------------------------
15:09:17,210 FIN&#160;&#160; | [HibernateSessionResource] ----- beginning hibernate tx 28678425 --------------------------------------------------------
### EXCEPTION ###########################################
15:09:17,217 SEV&#160;&#160; | [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.jbpm.pvm.internal.job.TimerImpl#50012]
&#160;&#160;&#160;&#160;&#160;at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
&#160;&#160;&#160;&#160;&#160;at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.HibernateSessionResource.prepare(HibernateSessionResource.java:56)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.StandardTransaction.commit(StandardTransaction.java:107)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.StandardTransaction.complete(StandardTransaction.java:64)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:61)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.jobexecutor.DispatcherThread.acquireJobs(DispatcherThread.java:126)
&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.jobexecutor.DispatcherThread.run(DispatcherThread.java:67)
### EXCEPTION ###########################################
15:09:17,219 FIN&#160;&#160; | [HibernateSessionResource] ----- rolling back hibernate tx 28848200 -----------------------------------------------------
15:09:17,270 FIN&#160;&#160; | [HibernateSessionResource] ----- beginning hibernate tx 1191324 --------------------------------------------------------

Thank you in advance.
</code></pre></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/535918#535918">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>