Hi,<br><br>   We have a fairly large BPMN process running inside a JPA persisted StatefulKnowledgeSession using Drools 5.4 &amp; JBPM 5.3. Our process involves timers, automated tasks, human tasks .... most of them are long-running processes, so a fault-tolerant scenario is a must.<br>

<br>    We&#39;ve found what seems to be a weird, weird bug in JBPM-Drools regarding the execution of BPMN processes. This is by best to summarize the problem:  <br><br>     &quot;We are unable to complete a human task after rehydrating a Drools knowledge session because in some circunstances the generated Drools&#39; workitems don&#39;t get persisted in the database after the completion of a previous task&quot;<br>

<br>    So, as the workitem is not in the database, when a human task client completes a task that is related to that non-existent workitem, the process doesn&#39;t get restarted. And the process fails.<br><br>    ¿Why does this happens? Lets see:<br>

<br>     When the processs is executed, different workitems get created, updated and eventually deleted during the execution of a process up until a human task is created ( in our process ). When living in a persistet knowledge session, the transaction that is associated to Drools&#39; thread is commited right after the human task is created in the human task server ... as it is a &quot;safe point&quot;. Nothing here. Everithing is consistent, if you look at the database you will see your session instance, your process instance, and the final human task workitem as it is the only workitem survivor after the execution ( whatever hadler-managed automated task that were executed before the human task are deleted and the human task workitem needs to survive as it&#39;s completion depends on asyncronous client interaction ).<br>

<br>     Now, if you connect to the human task server and complete that human task, a message is sent to the Drools session to update the state of the work item. The workitem gets updated, the process get restarted and the flow continues ... maybe generating a new human task ( which is our case ). At this very moment, if you take a look at the database, there are no automated-handled-task workitems ( as expected ) but there isn&#39;t any human task related work item, even worse, the task at the human task server is created, persisted and has a reference to the non-existant workitem.<br>

<br>    Days of debugging led us to what we think is the source of the problem: <br><br>    We found that the execution of the process after completing a task is being executed in the same thread as the one that receives the mina message that the human task server sends whenever a task is completed. This thread is not the same thread that executes the knowledgesession ( where the reteoo lives ) and so it doesn&#39;t have a transaction. By the way, we found that for  workitem persistence the JPAWorkitemManager never joins an active transaction. :(<br>

<br>    That&#39;s why invoking the persistence of a workitem as a consequence of restarting the execution of a process inside the thread that receives the mina messages makes the database inconsistent, and so invalidating all means to make JBPM fault tolerant by making Drools session persistent.<br>

<br>    We found a way to circunvent this problem, making all our human task nodes be followed by a event timer. That way, when the timer gets completed we force the execution of the process to live in the same thread that the reteoo session lives where a transaction is available and things get back to normal. But this is really dirty and wrong.<br>

<br>    Any thoughts?    <br><br>    We are really eager to be wrong whith this. :&#39;(<br><br>Greets,<br>    <br><br><br clear="all">Alberto R. Galdo<br><a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a><br>

<br><br>