Thanks for the reply, Kris.<br><br>I figured it might be something like that, but was thrown because one of the test cases in PersistentStatefulSessionTest (testPersistenceWorkItems3) does check for process state COMPLETE.<br>
<br>I worked around the issue by adding a ProcessEventListener that implements the afterProcessComplete() method.  Since my action upon process completion is to send a JMS message to the person who started the process, using an event listener is actually a little bit cleaner than checking process status after every session state change.<br>
<br>Regards,<br><br>Dan Nathanson<br><br>
<br><br><div class="gmail_quote">On Tue, Mar 8, 2011 at 5:19 PM, Kris Verlaenen <span dir="ltr">&lt;<a href="mailto:kris.verlaenen@cs.kuleuven.be">kris.verlaenen@cs.kuleuven.be</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Dan,<br>
<br>
Once you start using persistence, you should know that the process<br>
instance you are retrieving is no longer the internal process instance<br>
but a version of the process instance at the moment you requested it.<br>
This process instance however is disconnected, meaning that it will not<br>
automatically update when the internal process instance changes.  The<br>
main reason is that, when using persistence, process instances can be<br>
removed and reloaded from database at any time, so you basically get a copy.<br>
<br>
If you register a listener that listens for process instance completion<br>
right before inserting the list in testPersistenceState(), you will<br>
notice that this process instance gets completed and that the process<br>
instance state of the internal process instance is set to completed.<br>
The copy you still have from before still is in active state though.<br>
Since process instances that are completed are also removed from<br>
persistence as no longer necessary, you can&#39;t get the process instance<br>
in state completed.  That&#39;s why we test whether a process instance is<br>
completed by checking it is null when we try to retrieve it.  Another<br>
option would be to use a history logger of course.<br>
<br>
Kris<br>
<div class="im"><br>
Dan Nathanson wrote:<br>
&gt; More info...<br>
&gt;<br>
&gt; This behavior is reproducible in the Drools JPA test cases.<br>
&gt;<br>
&gt; In<br>
&gt; org.drools.persistence.session.PersistentStatefulSessionTest.testPersistenceState()<br>
&gt; and testPersistenceRuleSet(), if you add a breakpoint before loading<br>
&gt; the processInstance the last time (when it is null because the process<br>
&gt; has &quot;completed&quot;), you can see that processInstance.getState() returns<br>
&gt; 1 (ACTIVE) instead of 2 (COMPLETE).  I added the ConsoleLogger to the<br>
&gt; ksession and can see the &quot;AFTER RULEFLOW COMPLETED&quot; log message.<br>
&gt;<br>
&gt; In the other test cases, the state is correctly set to 2 after the<br>
&gt; process completes.<br>
&gt;<br>
&gt; On Mon, Mar 7, 2011 at 11:21 AM, Dan Nathanson &lt;<a href="mailto:dan@ddnconsulting.com">dan@ddnconsulting.com</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:dan@ddnconsulting.com">dan@ddnconsulting.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     Hi,<br>
&gt;<br>
&gt;     I&#39;m seeing some odd behavior in Drools Flow 5.1.1.  When using JPA<br>
&gt;     and creating a StatefulKnowledgeSession using<br>
&gt;     JPAKnowledgeService.newStatefulKnowledgeSession(), processes look<br>
&gt;     like they run to completion, but calling<br>
&gt;     RuleFlowProcessInstance.getState() on process instances created<br>
&gt;     froim this knowledge session returns 1 (STATE_ACTIVE).  Calling<br>
&gt;     getActiveNodeIds() throws a NullPointerException.<br>
&gt;<br>
&gt;     If I get a StatefulKnowledgeSession without JPA by calling<br>
&gt;     KnowledgeBase.newStatefulKnowledgeSession(), getState() returns 2<br>
&gt;     (STATE_COMPLETED).<br>
&gt;<br>
&gt;     I added<br>
&gt;     KnowledgeRuntimeLoggerFactory.newConsoleLogger(knowledgeSession)<br>
&gt;     and can see in both cases that the process is complete.<br>
&gt;<br>
&gt;     Has this been seen before?  Is it a known bug?  Am I doing<br>
&gt;     something wrong?<br>
&gt;<br>
&gt;     Regards,<br>
&gt;<br>
&gt;     Dan Nathanson<br>
&gt;<br>
&gt;<br>
</div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>