5 Replies Latest reply on Sep 29, 2005 9:21 AM by Koen Aers

    Transaction problems with JBoss Portal + JBPM

    Sven Schulz Newbie

      Hi,

      I am developing an application that integrates JBoss Portal and jBpm. However, I have a problem with transaction management. Whenever I try to commit on the JBpm session, I get the follwing exception:

      Caused by: javax.faces.el.EvaluationException: /deploy.xhtml @19,65 action="#{archive.deploy}": java.lang.RuntimeException: couldn't commit transaction
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 84 more
      Caused by: java.lang.RuntimeException: couldn't commit transaction
       at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:107)
       at org.jbpm.jpdl.par.ProcessArchiveDeployer.deployProcessDefinition(ProcessArchiveDeployer.java:83)
       at org.jbpm.jpdl.par.ProcessArchiveDeployer.deployZipInputStream(ProcessArchiveDeployer.java:47)
       at org.jbpm.jpdl.par.ProcessArchiveDeployer.deployZipInputStream(ProcessArchiveDeployer.java:42)
       at de.tccproducts.chameleon.portlets.archive.ArchiveBean.deploy(ArchiveBean.java:57)
       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.sun.el.parser.AstValue.invoke(AstValue.java:130)
       at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
       at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
       at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
       ... 85 more
      Caused by: org.hibernate.TransactionException: JDBC commit failed
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:110)
       at org.jbpm.db.JbpmSession.commitTransaction(JbpmSession.java:103)
       ... 97 more
      Caused by: java.sql.SQLException: You cannot commit during a managed transaction!
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:519)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.commit(WrappedConnection.java:451)
       at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:95)
       ... 98 more
      


      What's the problem here! I need a solution as soon as possible. Even if it's a dirty one.

      I use a hypersonic database for both jBpm and Portal. I use a preconfigured Portal (2.0.1RC1) + AS (4.0.2) installation. I copied the relevant items from the AS (4.0.2) + jBpm (3.0.1) installation into the preconfigured Portal server. Everything works fine, except for the transaction management. I think as both portal and jBpm use hibernate they must interfere somehow. Portal opening a managed transaction and jBpm trying to commit?! I changed my portal configuration to use the NoTxPortalDS datasource (which shouldn't use transactions, i suppose). Still no success!

      Any idea?

      Regards,
      Sven Schulz

        • 1. Re: Transaction problems with JBoss Portal + JBPM
          Viet Master

          using the tx datasource, try to deploy the session factory with the following properties :

          hibernate.transaction.flush_before_completion=true
          hibernate.transaction.auto_close_session=true
          hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
          hibernate.transaction.manager_lookup_classrg.hibernate.transaction.JBossTransactionManagerLookup
          


          the goal is that the hibernate transaction wrapper should not commit the underlying JTA transaction and should flush its data when the JTA tx commits.


          • 2. Re: Transaction problems with JBoss Portal + JBPM
            Sven Schulz Newbie

            Thank you Julien. I've done what you said. No success. My hibernate portal configuration now looks like

            <?xml version='1.0' encoding='utf-8'?>
            <!DOCTYPE hibernate-configuration PUBLIC
             "-//Hibernate/Hibernate Configuration DTD//EN"
             "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
            <hibernate-configuration>
             <session-factory
             name="java:portal/SessionFactory">
             <property name="connection.datasource">java:PortalDS</property>
             <property name="show_sql">false</property>
             <property name="transaction.flush_before_completion">true</property>
             <property name="transaction.auto_close_session">true</property>
             <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
             <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
            
             <!-- Force the dialect instead of using autodetection -->
             <!--
             <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
             -->
            
             <!-- Mapping files -->
             <mapping resource="org/jboss/portal/core/impl/role/RoleImpl.hbm.xml"/>
             <mapping resource="org/jboss/portal/core/impl/user/UserImpl.hbm.xml"/>
             <mapping resource="org/jboss/portal/core/impl/user/UserPref.hbm.xml"/>
             <mapping resource="org/jboss/portal/core/impl/user/UserPrefSet.hbm.xml"/>
             </session-factory>
            </hibernate-configuration>
            


            Hope you have more ideas :-)

            Regards,
            Sven Schulz

            • 3. Re: Transaction problems with JBoss Portal + JBPM
              Sven Schulz Newbie

              Wouldn't it be necessary to do this for the inner transaction (in jBpm). Since this one shouldn't commit but does (as requested in source code)?

              • 4. Re: Transaction problems with JBoss Portal + JBPM
                Viet Master

                what you can try is to use an EJB session bean with a simple method that you cann and has a declarative transaction attribute to REQUIRES_NEW.

                then in that EJB method you call your code that needs a transaction.

                I coded such a bean in my life so you can get the code here :

                http://anoncvs.forge.jboss.com:8080/viewrep/~raw,r=1.3/JBoss/nukes/nukes/src/main/org/jboss/nukes/core/ejb/UtilsEJB.java

                an example of usage is :

                UtilsEJB utils = ((UtilsEJBLocalHome)ctx.lookup(UtilsEJBLocalHome.JNDI_NAME)).create();
                utils.requiresNew(new UtilsEJB.Executable()
                {
                 System.out.println("this is running in its own transaction");
                });