7 Replies Latest reply on Mar 24, 2010 8:25 AM by jdboer

    jBPM 4.3 and Spring 3

    jochen_mader

      I got it working but I get a "Multiple Spring beans found for type interface java.util.Map returning the first one found" warning.

      Tracing around I found out that WireContext is looking for "deployments". It doesn't exist in the current context so it delegates to spring. There it uses java.util.Map to search for it and gets back a list containing "systemProperties" and "systemPreferences".

      Doesn't look right to me, although my processes work as expected

       

      the call causing the warnings:

      ProcessEngine engine = (ProcessEngine) context.getBean("processEngine");
      engine.getRepositoryService().createDeployment().addResourceFromClasspath("processdefinitions/hello.jpdl.xml").deploy();
      

       

      my jbpm config:

      <jbpm-configuration>
           <import resource="jbpm.jpdl.cfg.xml" />
           <import resource="jbpm.tx.spring.cfg.xml" />
           <import resource="jbpm.default.cfg.xml" />
           <import resource="jbpm.jpdl.cfg.xml" />
      </jbpm-configuration>
      

      And this spring configuration:

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      
           xsi:schemaLocation="http://www.springframework.org/schema/beans
                     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                      http://www.springframework.org/schema/context
                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">
      
           <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
      
           <bean id="processEngine" factory-bean="springHelper"
                factory-method="createProcessEngine" />
      
           <bean id="sessionFactory"
                class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
                <property name="dataSource" ref="dataSource" />
           </bean>
      
           <bean id="transactionManager"
                class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                <property name="sessionFactory" ref="sessionFactory" />
                <property name="dataSource" ref="dataSource" />
           </bean>
      
           <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
                destroy-method="close">
                <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
                <property name="url" value="jdbc:hsqldb:file:testdb" />
                <property name="username" value="sa" />
                <property name="password" value="" />
           </bean>
      </beans>
      

       

      Messed up the syntax highlighting

        • 1. Re: jBPM 4.3 and Spring 3
          mwohlf

          Hi Jochen,

           

          I had the same problem with jbpm4 and Spring3, to me it seems like the autowiring tries to lookup values for the some fields in the RepositorySessionImpl and RepositoryCacheImpl and searches the spring context for the field type.

          I resolved this by using

           

          <object class="org.jbpm.pvm.internal.repository.RepositoryCacheImpl" />

           

          instead of

           

          <repository-cache />

           

          in jbpm.default.cfg.xml

           

          The warnings were gone but the drawback is using an internal class in the config, so if someone got a better idea...

          • 2. Re: jBPM 4.3 and Spring 3
            jochen_mader

            Thanks a lot. That fixed it.

            I agree that the use of an internal class is not optimal. In our case it doesn't hurt too much as we are using JBPM inside JBoss and just need this scenario for unit tests outside the container.

            • 3. Re: jBPM 4.3 and Spring 3

              Hi Jochen,

              hi Michael,

               

              I have the same problem and I'm using jBPM4.3 with Spring 3 in a Tomcat 6.

               

              My Question: How did you do the changes inside the jbpm.default.cfg.xml???

               

              This is my jBPM-config

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

              I tryed to copy the content of the jbpm.default.cfg.xml to a new file in my classpath and import this one but everything ends in an exception that the file is not found. :-(

               

              Could you please help me?

               

              Greetings from Germany

              Sandro

              • 4. Re: jBPM 4.3 and Spring 3
                jochen_mader

                Sounds like a build problem to me.

                I just dropped it into my src/main/resources folder in my maven project and it worked.

                Did you check where the file ends up after compiling?

                • 5. Re: jBPM 4.3 and Spring 3
                  mwohlf

                  I don't use the jbpm.default.cfg.xml file I have everything in jbpm.cfg.xml which is picked up by the SpringHelper:

                   

                  <bean id="springHelper"

                        name="springHelper"

                        class="org.jbpm.pvm.internal.processengine.SpringHelper" >

                   

                       <property name="jbpmCfg" value="jbpm4.cfg.xml" />

                  </bean>

                   

                  I just added whatever I needed from the jbpm.default.cfg.xml

                  • 6. Re: jBPM 4.3 and Spring 3
                    jochen_mader

                    Similar here:

                     

                    <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
                    

                     

                    This config uses the default, which is jbpm.cfg.xml, but yours should work, too.

                    Check if the file is really where you expect it to be.

                    • 7. Re: jBPM 4.3 and Spring 3
                      jdboer

                      Hi,

                      A couple of weeks ago I wrote a blogpost about integrating jbpm 4.3 with Spring 3. It uses Spring's auto configuration so integrating it is just adding 1 line to your Spring context. This solution exposes all jbpm services in Spring.

                       

                      blogpost: http://diversit.eu/2010/01/10/jbpm-4-3-with-spring/