0 Replies Latest reply on Oct 26, 2005 12:35 PM by null null

    how to use Global (managed) transactions in jbpm

    null null Newbie

      Hi,
      I'm trying to implement the following process in jbpm:

      BEGIN GLOBAL TX
      1. An MDB creates a process instance
      2. This MDB signal() the instance
      3. The NODE that jbpm transitions to has an ActionHandler that generates a JMS message
      END GLOBAL TX
      

      What I am finding is the JMS message is being sent by the action class immediaetly, not when the MDB that creates the process instance commits. What I'd like to happen is all of the updates (the process definition to Oracle and the new JMS message to JBoss MQ) happens simultaneously.

      My configuration is as follows:
      - JBoss 4.0.2
      - JBPM 3.0.1
      - I've confgired Hibernate 3 to use Oracle for persistance with my jbpm.hibernate.properties as follows:
      hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
      # for Oracle 8 compatibility use
      #hibernate.dialect=org.hibernate.dialect.OracleDialect
      hibernate.show_sql=false
      #hibernate.c3p0.min_size=1
      #hibernate.c3p0.max_size=3
      hibernate.query.substitutions=true 1, false 0
      hibernate.connection.datasource=java:/MY_DS
      

      and Jbpm is persisting everything to oracle
      - The MY_DS Datasource is set up as an XA datasource as follows:
      my_ds-ds.xml
      <xa-datasource>
       <jndi-name>MY_DS</jndi-name>
       <track-connection-by-tx/>
       <isSameRM-override-value>false</isSameRM-override-value>
       <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
       <xa-datasource-property name="URL">JDBC:oracle:oci:@XXX</xa-datasource-property>
       <xa-datasource-property name="User">user</xa-datasource-property>
       <xa-datasource-property name="Password">passwd</xa-datasource-property>
       <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
       <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
       <!-- Checks the Oracle error codes and messages for fatal errors -->
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
       <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
       <no-tx-separate-pools/>
      
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
       <metadata>
       <type-mapping>Oracle9i</type-mapping>
       </metadata>
       </xa-datasource>
      


      I tried basing the advice code on this post:
      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=67431
      So I've updated the jbpm.hibernate.properties file to look like this:

      hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
      # for Oracle 8 compatibility use
      #hibernate.dialect=org.hibernate.dialect.OracleDialect
      hibernate.show_sql=false
      hibernate.query.substitutions=true 1, false 0
      hibernate.connection.datasource=java:/MY_DS
      
      # hibernate.show_sql=true
      
      # added to support XA TX
      hibernate.jndi.class=org.jboss.naming.NamingContextFactory
      #hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory
      hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
      hibernate.transaction.flush_before_completion=true
      hibernate.connection.release_mode=after_statement
      hibernate.transaction.auto_close_session=true

      However, when booting jbpm now reports the following exception. I get this exception whether I use net.sf.hibernate.transaction.JTATransactionFactory or org.hibernate.transaction.JTATransactionFactory
      I assumed that the original poster was using Hib 2.0, so I updated the package names accordingly.

      2005-10-26 12:28:19,861 INFO [org.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
      2005-10-26 12:28:19,861 ERROR [org.hibernate.transaction.TransactionFactoryFactory] TransactionFactory class not found
      java.lang.ClassNotFoundException: No ClassLoaders found for: org.hibernate.transaction.JTATransactionFactory
       at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:292)
       at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:475)
       at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:377)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:164)
       at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
       at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:37)
       at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:344)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:187)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
       at org.jbpm.db.JbpmSessionFactory.buildSessionFactory(JbpmSessionFactory.java:138)
       at org.jbpm.db.JbpmSessionFactory.<init>(JbpmSessionFactory.java:77)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:94)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:90)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:86)
       at org.jbpm.db.jmx.JbpmService.startService(JbpmService.java:18)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
       at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:418)
       at org.jboss.system.ServiceController.start(ServiceController.java:440)
       at org.jboss.system.ServiceController.start(ServiceController.java:440)
       at org.jboss.system.ServiceController.start(ServiceController.java:440)
       at org.jboss.system.ServiceController.start(ServiceController.java:440)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
       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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.JMXInvocationHandler.invoke(JMXInvocationHandler.java:273)
       at $Proxy29.start(Unknown Source)
       at org.jboss.deployment.XSLSubDeployer.start(XSLSubDeployer.java:229)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
       at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy8.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:501)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
       at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:418)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
       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 org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
       at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:434)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:315)
       at org.jboss.Main.boot(Main.java:195)
       at org.jboss.Main$1.run(Main.java:463)
       at java.lang.Thread.run(Thread.java:595)
      2005-10-26 12:28:19,871 ERROR [org.jbpm.db.jmx.JbpmService] Starting failed jboss.jbpm:name=DefaultJbpm,service=JbpmService
      org.hibernate.HibernateException: TransactionFactory class not found: org.hibernate.transaction.JTATransactionFactory
       at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:41)
       at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:344)
       at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:187)
       at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1509)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
       at org.jbpm.db.JbpmSessionFactory.buildSessionFactory(JbpmSessionFactory.java:138)
       at org.jbpm.db.JbpmSessionFactory.<init>(JbpmSessionFactory.java:77)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:94)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:90)
       at org.jbpm.db.JbpmSessionFactory.buildJbpmSessionFactory(JbpmSessionFactory.java:86)
       at org.jbpm.db.jmx.JbpmService.startService(JbpmService.java:18)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
       at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)