jBPM + Container Managed Transactions
bdepaz Jun 19, 2006 8:32 AMHi,
I need some more info on how to setup jBPM using container managed transactions:
Here's the scenario I'm targeting at:
A Stateless Session bean containing business methods will instantiate and invoke the JBPM Proces/Context. So I want jBPM to be using the same transaction that is being initiated when a business method on the session bean is being called.
What I've read from the jBPM userguide, is that I would have to disable transactions in jbpm so it will use container managed transactions. But I can't seem to manage to get it working.
Here's what I tried so far:
* hibernate.cfg.xml
defined the transaction properties.
<hibernate-configuration> <session-factory> <!-- jdbc connection properties --> <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property> <property name="hibernate.connection.datasource">jdbc/DefaultDS</property>
* jbpm.cfg.xml
Defined the persistence bean, setting the isTransactionEnabled=false, like it is being pointed out in the manual, but that seems to throw UnparsableExcpetions.
<jbpm-context> <service name="persistence"> <factory> <bean factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"> <field name="isTransactionEnabled"><false /></field> <field name="sessionFactoryJndiName"> <string value="java:/myHibSessFactJndiName" /> </field> <field name="dataSourceJndiName"> <string value="jdbc/DefaultDS" /> </field> </bean> </factory> </service> ... </jbpm-context>
The Exception I'm getting seems to mean that still, jBPM is trying to commit it's persistent objects in it's own transaction:
19-jun-2006 14:30:09 org.jbpm.svc.Services close SEVERE: problem closing service 'persistence' org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171) at org.jbpm.svc.Services.close(Services.java:211) at org.jbpm.JbpmContext.close(JbpmContext.java:141) at be.cm.health.test.facade.MetroFacade.createProcessInstance(MetroFacade.java:94) at be.cm.health.test.TestSessionBean.jbpmSetup(TestSessionBean.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:55) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52) at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69) at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:86) at TestSession_StatelessSessionBeanWrapper0.jbpmSetup(TestSession_StatelessSessionBeanWrapper0.java:155) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595) Caused by: org.hibernate.TransactionException: JDBC commit failed at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:130) at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161) ... 25 more Caused by: java.sql.SQLException: The method 'commit' cant be called when a global transaction is active. at oracle.oc4j.sql.spi.ConnectionHandle.oc4j_throwSQLExceptionIfGlobalTxActive(ConnectionHandle.java:407) at oracle.oc4j.sql.spi.ConnectionHandle.commit(ConnectionHandle.java:122) at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:139) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115) ... 26 more 2006-06-19 14:30:09.603 ERROR J2EE EJB8006 [TestSessionBean:public void be.cm.health.test.TestSessionBean.jbpmSetup()] exception occurred du ring method invocation: oracle.oc4j.rmi.OracleRemoteException: org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persis tence.JbpmPersistenceException: couldn't commit hibernate session}; nested exception is: org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hiberna te session}
Can somebody help me out with this? Maybe point me to the right direction on this?
Note: I'm running all this in an Oracle OC4J container, in case that should matter.
Kind Regards,
Bert