Just a quick note to inform that we've been able to solve this problem.

In our case this was happening because Hibernate wasn'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).

Seems that JBPM and Drools doesn't like anyone messing with the transaction and expect it to be managed by themselves.

We were using this property:

<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />

That didn't work when using PostgreSQL, we had to use this property:

<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />

With that property we get rid of the exception.

Alberto R. Galdo
argaldo@gmail.com



-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/IT/S/M s a C+++ L++ P E--- W++ w
M++ PS tv t++ b++ G h-- r+++ y+
------END GEEK CODE BLOCK------


On Fri, Nov 2, 2012 at 6:39 PM, Alberto R. Galdo <argaldo@gmail.com> wrote:

Hi,

  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.

  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's transaction JTA implementation.

  From time to time ( we haven't found a way to reproduce this, but clearly has occurrences in the execution of our application ) we are getting this kind of exceptions:


Caused by: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd

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 )

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 ).


Have any of you found this situation before? Any insight?









12:27:47,677 WARN  [com.arjuna.ats.arjuna] (pool-11-thread-1) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a802fb:-1f97a856:5093fdd2:620, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@79da2820 >: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1295) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.ejb.AbstractEntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1481) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.beforeCompletion(SynchronizationCallbackCoordinatorImpl.java:109) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)
        at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)
        at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:164)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)
        at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:117)
        at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
        at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:167)
        at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]
        at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:376) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]
        at org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:34) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]
        at org.drools.persistence.jpa.JpaTimerJobInstance.call(JpaTimerJobInstance.java:14) [drools-persistence-jpa-6.0.0-SNAPSHOT.jar:6.0.0-SNAPSHOT]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.6.0_18]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.6.0_18]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165) [rt.jar:1.6.0_18]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266) [rt.jar:1.6.0_18]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_18]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_18]
        at java.lang.Thread.run(Thread.java:636) [rt.jar:1.6.0_18]
Caused by: org.hibernate.exception.GenericJDBCException: Connection is not associated with a managed connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@253770bd


Alberto R. Galdo
argaldo@gmail.com

-