9 Replies Latest reply on Feb 10, 2011 5:42 PM by sotes

    jBPM 4.3 and Spring integration - multiple transaction managers

    patriciab


      I am working on an application that is using jBPM 4.3 and Spring 2.5. The integration with Spring is very easy, and is working pretty well.
      But I have a special scenario in my application, where I am working with multiple transaction managers, but only one of them is used for jBPM. When I ran the app, I got the warning below.

       

      ***** warning *******
      WARN  [org.jbpm.pvm.internal.env.SpringContext] Multiple Spring beans found for type interface org.springframework.transaction.PlatformTransactionManager returning the first one found

       

      What I would like, is to be able to control which bean is loaded from the Spring context into the jBPM context, when there are multiple implementations for the same interface.
      My question is whether anybody else came across to this issue, and if there is any solution/workaround to this already implemented.

       

      Thanks,

      Patricia

        • 1. Re: jBPM 4.3 and Spring integration - multiple transaction managers

          Hi,

           

          there wont be issues with multiple txn maagers.

          we have integrated jbpm4.3 with spring.

           

          i didnt fid any issue..please send me ur appcontxt.xml file.

           

          vijaya.

          • 2. Re: jBPM 4.3 and Spring integration - multiple transaction managers
            patriciab

            Thank you for your reply.

             

            I debugged the issue, and the problem seems to be on the SpringContext.java (line 60 I think), when it loads Spring beans from the context. In my case, there are 2 implementations for transaction manager. So, when running the app, SpringContext finds more than one transaction managers defined on the context, it takes the first one that it comes on the array, but gives me the warning I posted originally.
            The fix I see here, is to be able to specify which Spring bean name to load when there are multiple transaction managers defined on the context.

             

            If you have a different solution for this problem, I appreciate it.

             

            Below is a snippet from my context.xml and jbpm.cfg.xml:

             

            <!-- context.xml ---->

             

            <bean id="transactionManager"
                      class="org.springframework.orm.hibernate3.HibernateTransactionManager"
                      p:sessionFactory-ref="applicationSessionFactory">
            </bean>
               
            <bean id="SisStageTransactionManager"
                      class="org.springframework.orm.hibernate3.HibernateTransactionManager"
                      p:sessionFactory-ref="sisStageSessionFactory">                
            </bean>

             

            <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
                   <property name="jbpmCfg" value="jbpm4/jbpm.cfg.xml"/>
            </bean>

             

            <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />

             


            <!-- jbpm.cfg.xml ---->
            <jbpm-configuration>

             

                <import resource="jbpm.default.cfg.xml" />
                <import resource="jbpm.businesscalendar.cfg.xml" />
                <import resource="jbpm.tx.spring.cfg.xml" />
                <import resource="jbpm.jpdl.cfg.xml" />
                <import resource="jbpm.identity.cfg.xml" />
                <import resource="jbpm.jobexecutor.cfg.xml" />
                <import resource="jbpm.default.scriptmanager.xml" />
               
            </jbpm-configuration>   
            <!-- context.xml ---->

             

             

             

            Thanks,
            Patricia

            • 3. Re: jBPM 4.3 and Spring integration - multiple transaction managers
              sotes

              Hi Patricia, I have the same problem in my application. Did you found any solution???

              thanks renier

              • 4. Re: jBPM 4.3 and Spring integration - multiple transaction managers

                Could you try having a class (say ABC) which extends HibernateTransactionManager. Now define  SisStageTransactionManager using this new class..may not be best of solution..but may work....

                • 5. Re: jBPM 4.3 and Spring integration - multiple transaction managers
                  rebody

                  Hi rams,

                   

                  If you want to specify a transactionmanager that declare in the spring application context.  You could change the <spring-transaction-interceptor> in jbpm.tx.spring.cfg.xml.

                   

                  <spring-transaction-interceptor  transaction-manager="transactionManager"/>
                  

                   

                  Change the transaction-manager attribute to the real bean name in the xml, and jBPM will use it to find the transactionManager by the name we set.

                  • 6. Re: jBPM 4.3 and Spring integration - multiple transaction managers
                    sotes

                    Hi HuiSheng Xu

                    can you provide my the jbpm.cfg.xml and the applicationCtx.xml files?? I cant found a very clear doc about the jbpm configuration. thanks

                    • 7. Re: jBPM 4.3 and Spring integration - multiple transaction managers
                      rebody

                      Hi Renier,

                       

                      Here is the sample.  Please have a try.

                      • 8. Re: jBPM 4.3 and Spring integration - multiple transaction managers
                        sotes

                        thank for your help HuiSheng Xu, the sample work perfect. you've helped me a lot

                        • 9. jBPM 4.3 and Spring integration - multiple transaction managers
                          sotes


                          I has been testing the jbpm with multiple sessionFactory but I found this warning ¨WARN [org.jbpm.pvm.internal.env.SpringContext] - Multiple Spring beans found for type interface org.hibernate.SessionFactory returning the first one found¨, Any one know how I can fixed?