did you try replacing: <br>ksession.getWorkItemManager()<div id=":1g" class="ii gt">.completeWorkItem(workItem.getId(),
 results);<br><br>for<br><br>manager.completeWorkItem(workItem.getId(), results);<br>?<br><br>where do you get the ksession reference?<br><br>Greetings<br></div><br><br><div class="gmail_quote">2010/7/23 Rory Farrell <span dir="ltr">&lt;<a href="mailto:rjf@bellsouth.net">rjf@bellsouth.net</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi, I was trying to get persistence working in Drools 5.1.0.M2 but ran into some issues:<br>

<br>
<a href="http://drools-java-rules-engine.46999.n3.nabble.com/Persistence-with-Drools-5-1-0-M2-td973691.html#none" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Persistence-with-Drools-5-1-0-M2-td973691.html#none</a><br>

<br>
I decided to try with 5.0.1 to see if I had any better luck.  I ran into the same problem:<br>
<br>
java.lang.NullPointerException<br>
        at<br>
org.drools.persistence.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:85)<br>
<br>
Line 85 is:<br>
<br>
workItemInfo = em.find(WorkItemInfo.class, id);<br>
<br>
The JPAWorkItemManager tries to retrieve the EntityManager from the<br>
environment:<br>
<br>
EntityManager em = (EntityManager)<br>
this.workingMemory.getEnvironment().get( EnvironmentName.ENTITY_MANAGER );<br>
<br>
and the EntityManager is not in the environment.<br>
<br>
The EntityManagerFactory is in the environment and I see where the<br>
SingleSessionCommandService class uses the factory to instantiate an<br>
EntityManager, but it never gets put in the environment for the<br>
JPAWorkItemManager to retrieve it.<br>
<br>
I was using the UIWorkItemHandler from the example applications.  I wrote a dummy WorkItemHandler to replace the UIWorkItemHandler:<br>
<br>
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {<br>
    Map&lt;String, Object&gt; results = new HashMap&lt;String, Object&gt;();<br>
    System.out.println(&quot;Before complete work item&quot;);<br>
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), results);<br>
    System.out.println(&quot;After complete work item&quot;);<br>
}<br>
<br>
This fixed the NullPointerException but the role flow process was not detecting that the work item had been completed.  I debugged into the completeWorkItem code and I found that JPAWorkItemManager class called the ProcessInstance.signalEvent method with &quot;workItemCompleted&quot; but the WorkflowProcessInstanceImpl.signalEvent method found no eventListeners for that type.<br>

<br>
I can see the eventListeners for &quot;workItemCompleted&quot; and for &quot;workItemAborted&quot; when I do a ksession.update but the eventListeners are not there when my WorkItemHandler is called.<br>
<br>
This only happens when the flow is resumed from an Event Wait flow by updating a FactHandle.  If the flow goes directly to the Human Task node then the workItem is completed correctly.<br>
<br>
I attached a screenshot of the rule flow.  If there are no missing certification when the process is started then the Human Task is completed successfully.  If there are missing certifications and then the constraint is satisfied by updating a FactHandle then the workItem is not completed correctly and the flow does not proceed to sending the email.<br>

<br>
This all works correctly if I don&#39;t try to persist the rule flow.<br>
<br>
Hopefully someone can provide some insight as to what is going on here.<br>
<br>
Regards,<br><font color="#888888">
Rory<br>
</font><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>
<br></blockquote></div><br><br clear="all"><br>-- <br> - CTO @ <a href="http://www.plugtree.com">http://www.plugtree.com</a>  <br> - MyJourney @ <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> <br> - Salatino &quot;Salaboy&quot; Mauricio -<br>