Just a quick note to inform that we&#39;ve been able to solve this problem.<br><br>In our case this was happening because Hibernate wasn&#39;t able to find the JPA configured Transaction managed ( which in our case is JBoss Tx ). That made Hibernate fall back to auto_commit=true mode and eager releasing the resources inside a transaction  ( releasing the connection after commiting it). <br>

<br>Seems that JBPM and Drools doesn&#39;t like anyone messing with the transaction and expect it to be managed by themselves.<br><br>We were using this property:<br><br>&lt;property name=&quot;hibernate.transaction.manager_lookup_class&quot; value=&quot;org.hibernate.transaction.JBossTransactionManagerLookup&quot; /&gt;<br>

<br>That didn&#39;t work when using PostgreSQL, we had to use this property:<br><br>&lt;property name=&quot;hibernate.transaction.jta.platform&quot; value=&quot;org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform&quot; /&gt;<br>

<br>With that property we get rid of the exception.<br><div class="gmail_extra"><br clear="all">Alberto R. Galdo<br><a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a><br><br><br><br>-----BEGIN GEEK CODE BLOCK-----<br>

Version: 3.12<br>GCS/IT/S/M s a C+++ L++ P E--- W++ w <br>M++ PS tv t++ b++ G h-- r+++ y+<br>------END GEEK CODE BLOCK------<br>
<br><br><div class="gmail_quote">On Fri, Nov 2, 2012 at 6:39 PM, Alberto R. Galdo <span dir="ltr">&lt;<a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>Hi, <br><br>  We have an application that uses JBPM and Drools to execute BPMN 2.0 processes. Our knowledge session gets persisted in a PostgreSQL database and so it is StatefulKnowledgeSession.<br><br>  Our application runs inside a JBoss 7.x server, our JPA context uses the bundled Hibernate 4.x as entity manager and JBoss Tx service ( bundled with jboss) as hibernate&#39;s transaction JTA implementation.<br>


<br>  From time to time ( we haven&#39;t found a way to reproduce this, but clearly has occurrences in the execution of our application ) we are getting this kind of exceptions:<br><br><br>Caused by: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd<br>


<br>during commits induced by Drools [org.drools.persistence.jta.JtaTransactionManager.commit] ( as you can see in the full stacktrace attached at the bottom of this mail ) <br><br>The problem here is that our processes stop executing because of this exception. For instance, there are times when this exception arises when commiting a transaction that contains a human task persistance and because of the exception this information is lost, breaking our processes ( now nobody will never be ever able to restart the process by completing a human task ).<br>


<br><br>Have any of you found this situation before? Any insight?<br><br><br><br><br><br><br><br><br><br>12:27:47,677 WARN  [com.arjuna.ats.arjuna] (pool-11-thread-1) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple&lt; 0:ffffc0a802fb:-1f97a856:5093fdd2:620, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@79da2820 &gt;: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd<br>


        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]<br>        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]<br>


        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]<br>        at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]<br>


        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]<br>


        at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]<br>        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)<br>


        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)<br>        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)<br>        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)<br>


        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)<br>        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)<br>


        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)<br>        at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)<br>


        at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]<br>        at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]<br>


        at org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:34) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]<br>        at org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:14) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]<br>


        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.6.0_18]<br>        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.6.0_18]<br>        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165) [rt.jar:1.6.0_18]<br>


        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266) [rt.jar:1.6.0_18]<br>        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_18]<br>


        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_18]<br>        at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]<br>Caused by: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd<span class="HOEnZb"><font color="#888888"><br>


<br><br clear="all">Alberto R. Galdo<br><a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a><br><br>-<br>
</font></span></blockquote></div><br></div>