5 Replies Latest reply on Mar 7, 2010 11:23 PM by praneet

    integrating spring 2.5.6 with jbpm 4.3

    praneet

      hello every one

        to configure spring with jbpm 4.0 i used to write following code in applicationcontext.xml

       

      <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">

      <property name="sessionFactory" ref="sf"></property>

      <constructor-arg value="jbpm.cfg.xml"></constructor-arg>

      </bean>

       

       

      but the above class (org.jbpm.pvm.internal.cfg.SpringConfiguration)

      is not present in jbpm 4.3 then how to integrate in 4.3

        • 1. Re: integrating spring 2.5.6 with jbpm 4.3
          khoying

          This appears to have been changed.  I just started with jBPM and seem to have it all up and running under Spring.  My Spring configuration looks like this:

           

           

          <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="dataSource" ref="dataSource" />
                    
               <!-- This config is for unit tests as the jar will not exist yet.  -->
               <!-- It does not work at runtime since the files will be located in a jar and hibernate will not pick them up.  -->
               <property name="mappingLocations">
                    <value>classpath*:**/*.hbm.xml</value>
               </property>
          
               <!-- This config does not work for unit tests as the jar will not exist yet.  -->
               <!-- It does work at runtime since the files will be located in a jar.  -->
               <property name="mappingJarLocations">
                    <list>
                         <value>classpath*:**/services.jar</value>
                         <value>classpath*:**/jbpm-pvm-*.jar</value>
                    </list>
               </property>
          
               <property name="hibernateProperties">
                    <props>
                         <prop key="hibernate.dialect">
                              org.hibernate.dialect.Oracle10gDialect
                         </prop>
                         <prop key="hibernate.show_sql">false</prop>
                         <prop key="hibernate.generate_statistics">false</prop>
                    </props>
               </property>
                    
               <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
                    
               <property name="eventListeners">
                    <map>
                         <entry key="merge">
                              <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
                      </entry>
                    </map>
               </property>
          </bean>
          
          • 2. Re: integrating spring 2.5.6 with jbpm 4.3
            unsavory

            Hi Praneet,

             

            You also do not specify your persistence needs.  The post above will work if you are using plain hibernate.  You will need a different configuration though if you are using hibernate with JPA.

             

            This thread should be of help in case you need to configure Spring with jBPM 4.3 and you are using JPA:  http://community.jboss.org/thread/147177?tstart=0

             

            Specifically, I wrote about it here:  http://captaincaveman.posterous.com/jbpm-43-spring-3-jboss-jpa-jta-configuration

             

            Hope it helps.

            • 3. Re: integrating spring 2.5.6 with jbpm 4.3
              praneet

              am using hibernate

               

               

              SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

              org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine' defined in ServletContext resource [/WEB-INF/classes/jbpm4-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [protected org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine()] threw exception; nested exception is java.lang.NullPointerException

                   at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:423)

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:901)

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:815)

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

                   at java.security.AccessController.doPrivileged(Native Method)

                   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)

                   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)

                   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)

                   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)

                   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

                   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)

                   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)

                   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)

                   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)

                   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)

                   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)

                   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

                   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)

                   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)

                   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

                   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)

                   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)

                   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)

                   at org.apache.catalina.core.StandardService.start(StandardService.java:516)

                   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)

                   at org.apache.catalina.startup.Catalina.start(Catalina.java:566)

                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                   at java.lang.reflect.Method.invoke(Unknown Source)

                   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)

                   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

              Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [protected org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine()] threw exception; nested exception is java.lang.NullPointerException

                   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:127)

                   at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:414)

                   ... 32 more

              Caused by: java.lang.NullPointerException

                   at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:152)

                   at org.jbpm.pvm.internal.processengine.SpringProcessEngine.create(SpringProcessEngine.java:70)

                   at org.jbpm.pvm.internal.cfg.ConfigurationImpl.buildProcessEngine(ConfigurationImpl.java:92)

                   at org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine(SpringHelper.java:47)

                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                   at java.lang.reflect.Method.invoke(Unknown Source)

                   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115)

                   ... 33 more

              • 4. Re: integrating spring 2.5.6 with jbpm 4.3
                unsavory
                Could you please post your configuration so we can see what might be wrong?  Please post your applicationContext.xml and jbpm.cfg.xml
                • 5. Re: integrating spring 2.5.6 with jbpm 4.3
                  praneet

                  this is my applicationcontext.xml

                   

                  <?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:aop="http://www.springframework.org/schema/aop"

                       xsi:schemaLocation="http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd

                            http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd

                            http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd

                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd

                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"

                       xmlns:context="http://www.springframework.org/schema/context"

                       xmlns:p="http://www.springframework.org/schema/p"

                       xmlns:tx="http://www.springframework.org/schema/tx"

                       xmlns:util="http://www.springframework.org/schema/util">

                      

                  <tx:annotation-driven transaction-manager="transactionManager"/>

                   

                      

                      

                  <bean id="ds"

                            class="org.springframework.jdbc.datasource.DriverManagerDataSource">

                            <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>

                            <property name="url" value="jdbc:mysql://localhost/praneetjbpm43" />

                            <property name="username" value="root"></property>

                            <property name="password" value="root"></property>

                           

                       </bean>

                   

                   

                  <bean

                    id="transactionManager"

                    class="org.springframework.orm.hibernate3.HibernateTransactionManager"

                    p:sessionFactory-ref="sf" />

                   

                  <bean id="sf" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

                   

                  <property name="dataSource" ref="ds"></property>

                  <property name="schemaUpdate" value="true"></property>

                   

                  <property name="hibernateProperties">

                  <props>

                  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>

                  <prop key="hibernate.show_sql">true</prop>

                  <prop key="hibernate.hbm2ddl.auto">update</prop>

                  <prop key="hibernate.query.substitutions">true 1, false 0</prop>

                   

                  </props>

                  </property>

                   

                  <property name="mappingLocations">

                  <list>

                  <value>classpath:jbpm.execution.hbm.xml</value>

                  <value>classpath:jbpm.history.hbm.xml</value>

                  <value>classpath:jbpm.task.hbm.xml</value>

                  <value>classpath:jbpm.repository.hbm.xml</value>

                  <value>classpath:jbpm.identity.hbm.xml</value>

                  </list>

                  </property>

                   

                  <!--  <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />

                   

                  -->

                   

                   

                  </bean>

                   

                   

                  <util:list id="annotatedHibernateClasses"></util:list>

                   

                  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">

                  <property name="sessionFactory" ref="sf"></property>

                  </bean>

                   

                   

                  <!-- ========================= Configuring JBPM4.3 ============================= -->

                   

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

                   

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

                   

                  </bean>

                   

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

                  </bean>

                   

                   

                   

                   

                   

                  </beans>

                   

                   

                  this is my jbpm.cfg.xml

                   

                  <?xml version="1.0" encoding="UTF-8"?>

                  <jbpm-configuration>

                       <import resource="jbpm.jpdl.cfg.xml" />

                       <import resource="jbpm.identity.cfg.xml" />

                       <!-- <import resource="jbpm.jobexecutor.cfg.xml" /> -->

                      

                       <process-engine-context>

                      

                      <string name="spring.cfg" value="applicationContext.xml" />

                            <repository-service />

                            <repository-cache />

                            <execution-service />

                            <history-service />

                            <management-service />

                            <identity-service />

                            <task-service />

                            <command-service>

                                 <retry-interceptor />

                                 <environment-interceptor />

                                 <spring-transaction-interceptor />

                            </command-service>

                            <script-manager default-expression-language="juel"

                                 default-script-language="juel"

                                 read-contexts="execution, environment, process-engine, spring"

                                 write-context="">

                                 <script-language name="juel"

                                      factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />

                            </script-manager>

                            <authentication />

                            <id-generator />

                            <types resource="jbpm.variable.types.xml" />

                            <address-resolver />

                            <business-calendar>

                                 <monday hours="9:00-12:00 and 12:30-17:00" />

                                 <tuesday hours="9:00-12:00 and 12:30-17:00" />

                                 <wednesday hours="9:00-12:00 and 12:30-17:00" />

                                 <thursday hours="9:00-12:00 and 12:30-17:00" />

                                 <friday hours="9:00-12:00 and 12:30-17:00" />

                                 <holiday period="01/07/2008 - 31/08/2008" />

                            </business-calendar>

                       </process-engine-context>

                       <transaction-context>

                       <transaction type="spring" />

                            <repository-session />

                            <db-session />

                            <message-session />

                            <timer-session />

                            <history-session />

                            <hibernate-session current="true" />

                            <mail-session>

                      <mail-server>

                        <session-properties>

                          <property name="mail.smtp.host" value="localhost" />

                          <property name="mail.smtp.port" value="25" />

                          <property name="mail.from" value="system@localhost.com" />

                        </session-properties>

                      </mail-server>

                    </mail-session>

                       </transaction-context>

                  </jbpm-configuration>