Skip to content


Demo on Spring Integration with jBPM4

After my presentation at J-Spring, I received a lot of feedback. The general question was how the Spring Integration would fit into a project. To fulfill this question, I have created following demo, which I’ll discuss in detail.

I have chosen a typical JSF-Spring-Hibernate stack as a base, and added jbpm4. The demo starts simple processes, just to prove the integration is a working fact.

This is release 0.1, which means I just finished a rudimentary version. However, I’ll keep updating and adding following features:

  • Timers
  • Forks
  • Invoking Spring beans

Don’t hesitate to subscribe so you’ll find out when newer versions are available.

Installation from SVN

  1. Checkout

    svn checkout 
    http://jbpm4-spring-demo.googlecode.com/svn/trunk/
    jbpm4-spring-demo-read-only 
    
    (All on 1 line)
    
  2. Download the jbpm4 maven dependencies. The spring integration is not yet part of any released jbpm4. Extract them into the org folder in your .m2/repository folder.
  3. enter following maven command in your checked out folder:
     mvn jetty:run

Running just the WAR:

  1. Download the war file.
  2. Drop it into jboss, tomcat, … and run it.

The integration:

If you would like to find more information about how it’s done, please look at my slides here.

The short version: We remove some dependencies from the jbpm-config, and add them into the spring-config. The integration will then search the required dependencies in the jbpm-contexts and then move on to the spring-context.

The dependencies we want Spring to provide are following:

  • Hibernate Session factory
  • Transaction Manager

But in essence other dependencies could be added. Since jBPM4 uses Hibernate for persistence, we need to add the mapping files to the sessionfactory:
From applicationContext-common.xml:

<bean id="sessionFactory"
	class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
	<property name="dataSource" ref="dataSource" />
	<property name="hibernateProperties">
		<props>
			<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
			<prop key="hibernate.show_sql">true</prop>
			<prop key="hibernate.hbm2ddl.auto">create-drop</prop>
		</props>
	</property>
	<property name="configLocations">
		<list>
			<value>classpath:be/inze/spring/demo/hibernate.cfg.xml</value>
		</list>
		</property>
	<property name="mappingLocations">
		<list>
			<value>classpath:jbpm.execution.hbm.xml</value>
			<value>classpath:jbpm.repository.hbm.xml</value>
			<value>classpath:jbpm.jpdl.hbm.xml</value>
			<value>classpath:jbpm.task.hbm.xml</value>
			<value>classpath:jbpm.history.hbm.xml</value>
		</list>
	</property>
</bean>

Own hbm files can be added as well (or mixed with annotations).

The jbpm.cfg.xml has been altered a bit. Changes (2 of them) are marked in bold:
From jbpm.cfg.xml:

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

<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">

  <process-engine-context>

    <repository-service />
    <repository-cache />
    <execution-service />
    <history-service />
    <management-service />
    <task-service />
    <identity-service />
    <command-service>
      <retry-interceptor />
      <environment-interceptor />
      <spring-transaction-interceptor current="true"/>

    </command-service>

    <hibernate-configuration>
      <cfg resource="jbpm.hibernate.cfg.xml" />
    </hibernate-configuration>

    <deployer-manager>
      <jpdl-deployer />
    </deployer-manager>

    <script-manager default-expression-language="juel"
                    default-script-language="juel"
                    read-contexts="execution, environment,
                                   process-engine"
                    write-context="">
        <script-language name="juel"
factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
    </script-manager>

    <authentication />

    <job-executor auto-start="false" />

    <id-generator />
    <types resource="jbpm.variable.types.xml" />

    <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>
    <repository-session />
    <pvm-db-session />
    <job-db-session />
    <task-db-session />
    <message-session />
    <timer-session />
    <history-session />
    <transaction />

    <hibernate-session />

    <hibernate-session current="true" />
    <identity-session />
  </transaction-context>

</jbpm-configuration>

spring-transaction-interceptor: The standard-transaction-interceptor will start and commit transactions. Instead, we want jbpm to reuse an existing transaction. The current=true forces the interceptor to check if a transaction already exists. It will crash else. On current=false, a new transaction will be created.

<hibernate-session current=”true” />: The current=true defines that we will use the hibernate-session that is available, no new one will be created.

Exposing beans:

When configuration is done, one can access the beans as follows:

<bean id="jbpmConfiguration"
   class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
	<constructor-arg
          value="be/inze/spring/demo/jbpm.cfg.xml" />
</bean>

<bean id="processEngine" factory-bean="jbpmConfiguration"
   factory-method="buildProcessEngine" />
<bean id="repositoryService" factory-bean="processEngine"
   factory-method="getRepositoryService" />
<bean id="executionService" factory-bean="processEngine"
   factory-method="getExecutionService" />

Feedback

Any feedback, positive AND negative is highly appreciated, either by comment or mail me at

Posted in jboss.


48 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Nils Preusker says

    Hi Andries, thanks for the post! I’m looking at the code right now and it looks great. Just one remark, the svn URL is not correct, it should be this: svn checkout http://jbpm4-spring-demo.googlecode.com/svn/trunk/

    Cheers! Nils

  2. Rams says

    Hi Andries,

    Thanks for the post, been really helpful. Wanted to know if you tried your hands around custom task’s (taskinstancefactory in jbpm3). Any pointers on how its changed in version 4? lot of classes have changed from 3 :(

    Cheers,
    Rams

  3. Anonymous says

    Tasks are now Activities. In RC1, it will be possible to add custom ActivityBehaviour implementations into your own processes.

  4. Andries Inzé says

    Rams,

    I’ve updated the demo with latest code. It is now possible to write something like:

    java name="springBean" expr="#{echoService}"
    method="sayHello">
    transition name="to give up" to="give up" g="-70,-22"/>
    /java>

    I’ll update the demo soon.

  5. RG says

    Hi, I followed the “Installation from SVN” from 1-3. What will be the next step? thanks

  6. Andries Inzé says

    RG,

    The application will be accessible at http://localhost:8080/jbpm4-spring/ .

    However, the code on SVN has already been updated to match CR1 of Jbpm4.

    You can still get the latest version of jbpm4 installed by running
    svn checkout http://anonsvn.jboss.org/repos/jbpm/jbpm4/trunk/
    mvn install

    This will install the dependencies into your local repository.

  7. gigliglich says

    Hi, I downloaded the war file then placed it in my tomcat webapps, then I ran it, but i get http status 404 after i accessed http://localhost:8080/jbpm4-spring-demo/

  8. Andries Inzé says

    Try jbpm4-demo (might made a typo there).

    Can you paste stacktrace from logs?

    KR,
    Andries

  9. gigliglich says

    Hi Andries,

    I tried using jbpm4-demo but the output is shown below.

    ——————————–
    from http://localhost:8080/jbpm4-demo/
    ——————————–

    HTTP Status 404 – /jbpm4-demo/

    type Status report

    message /jbpm4-demo/

    description The requested resource (/jbpm4-demo/) is not available.

    Is this the stacktrace from catalina logs below? thanks again for the support.

    ——————————–
    from /Library/Tomcat/Home/logs/catalina.2009-06-26.log
    ——————————–

    Jun 26, 2009 11:26:21 AM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
    Jun 26, 2009 11:26:22 AM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Jun 26, 2009 11:26:22 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 578 ms
    Jun 26, 2009 11:26:22 AM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jun 26, 2009 11:26:22 AM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
    Jun 26, 2009 11:26:22 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive jbpm4-spring-demo.war
    Jun 26, 2009 11:26:24 AM org.apache.catalina.core.StandardContext addApplicationListener
    INFO: The listener “com.sun.faces.config.ConfigureListener” is already configured for this context. The duplicate definition has been ignored.
    Jun 26, 2009 11:26:25 AM com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing Sun’s JavaServer Faces implementation (1.2_04-b16-p02) for context ‘/jbpm4-spring-demo’
    Jun 26, 2009 11:26:47 AM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    Jun 26, 2009 11:26:47 AM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    Jun 26, 2009 11:26:47 AM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/40 config=null
    Jun 26, 2009 11:26:47 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 25655 ms

    ——————————–

  10. Andries Inzé says

    Does not really do anything :s
    I’ll try it myself at home.

  11. gigliglich says

    ok Anries..thanks

  12. Andries Inzé says

    Try:
    http://localhost:8080/jbpm4-spring-demo/index.jsf

    Don’t yet know why it works in jetty but failed in tomcat. Looking into it. (tested on tomcat 6).

  13. gigliglich says

    Thanks Andries. the link worked in tomcat.

  14. Alex says

    Hi,

    your example is great. I would like to use jbpm4 in OSGI environment with spring integration but i have a huge problem- i cannot call spring beans from task. could you point me to the place in your configuration files where you include this functionality.

  15. Andries Inzé says

    Alex,

    Check http://www.inze.be/andries/2009/06/28/documentation-spring-jbpm-integration/

    You need to add the spring-context to the script-manager.

  16. Alex says

    Thank you Andries for the quick answer. But.. i have one more question! :) I have found these lines in your example (workflow definition):

    could you say what jBPM objects could be injected as (or other) types? where i can find such information? The jBPM documentaion is pretty bad :(

  17. Alex says

    here are the lines:
    <arg>
    <env type=”org.jbpm.pvm.internal.history.HistorySession”/>
    </arg>

  18. zhangjin says

    I running the code,the error is couldn’t interpret the dom model,
    org.springframework.beans.factory.BeanCreationException: Error creating bean wi
    h name ‘processEngine’ defined in class path resource [be/inze/spring/demo/appl
    cationContext-process.xml]: Invocation of init method failed; nested exception
    s org.jbpm.api.JbpmException:
    error: couldn’t interpret the dom model: java.lang.AbstractMethodError : java
    lang.RuntimeException: java.lang.AbstractMethodError

  19. Anonymous says

    I’d appreciate any help on the following:

    The process engine is supposed to be deployed as a service on Jboss and on starting the app server a reference to the ProcessEngine is bound to JNDI.
    Let’s say I’m deploying a process that has some classes with it (i.e. some AssigmentHandlers).
    I’d like to have another app deployed on the server that would get the reference from jndi to the ProcessEngine and would provide a GUI for working with the process.
    What I’d like to achieve is to have the assignment handler (that’s with the process) dependecy injected with spring beans that do some business logic and that are defined in the GUI web app.

    Maybe the assignment handlers should be in the GUI web-app but then how would the process engine find them?

    A more general problem: I’d like to have one central repository for processes and a few web-apps that work with selected processes. Should the ProcessEngine be declared once and made available through JNDI to the apps or should each web-app create its own ProcessEngine (that would possibly use the same db tables)?

    Could I please have Your insight on this?

  20. Andries Inzé says

    I don’t have a great answer on this. It might be more productive to ask the same question on the forums.

    KR,
    Andries

  21. Partho says

    Hi Andries,

    I have tried out Spring Integration with JBPM4 using Hibernate. That worked fine.But the project I am working on uses JPA transaction manager and HibernateVendor Adaptor internally.So is there a way I can do the integration here? Is there a way I can access the Hibernate session context used by JBPM?

  22. Andries Inzé says

    SInce you are already bound to Hibernate (via jBPM), you could expose the sessionFactory with the HibernateJpaVendorAdapter.getEntityManagerFactoryInterface .

    You can do that by doing
    bean id=”sessionFacotory” factory-method=”getEntityManagerFactoryInterface ” factoryBean=”jpaVendorAdaptor”

    The session should already be reused, since the integration looks for a PlatformTransactionManager.

    Please let me know if it works.

  23. Partho says

    Hi Andries,

    Thanks for the quick response.I tried to extract the sessionFactory as per your instruction(configurations given below).But still I am getting the same error(stack trace provided below)
    Configuration: Spring configuration

    Spring config for JBPM integration:

    Here I have injected the session factory I obtained from jpaVendorAdaptor into the Spring Configuration for JBPM.

    The exception is the following:
    org.jbpm.api.JbpmException: No platformTransaction manager defined.Testing the exception
    at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:61)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:59)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:70)
    ———————
    I have also looked into JBPM4 source code and found the error is occuring at the following point:
    Class:org.jbpm.pvm.internal.tx.SpringTransactionInterceptor
    Code:
    PlatformTransactionManager platformTransactionManager = environment.get(PlatformTransactionManager.class);
    if (platformTransactionManager == null) {
    throw new JbpmException(“No platformTransaction manager defined.”);
    }
    I am not able to set the PlatformTransactionManager into the environment variable.

    My questions are:
    1.How do I ask JBPM to use my transaction manager, which is org.springframework.orm.jpa.JpaTransactionManager?
    2.If 1 is not directly possible, is there a way to set the hibernate session (Extracted out of JPA EntityManager) programatically in JBPM Context (which facility was earlier there in JBPM 3.x) ?

  24. Partho says

    Hi Andries,

    In my last post the configurations didn’t appear…may be of xml tags…I am trying to post those again…

    Configuration: Spring configuration

    <tx:annotation-driven transaction-manager=”txManager”/>

    <bean id=”jpaVendorAdptr” “org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter”>
    <property name=”databasePlatform” value=”${database.dialect}”/>
    <property name=”showSql” value=”${database.showSql}” />
    <property name=”generateDdl” value=”${database.generateDdl}” />
    </bean>

    <bean id=”entityManagerFactory”
    class=”org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean”>
    <property name=”persistenceUnitName” value=”something”/>
    <property name=”dataSource” ref=”dataSource” />
    <property name=”jpaVendorAdapter” ref=”jpaVendorAdptr”>
    </property>
    </bean>

    <!– for hibernate integration –>
    <bean id=”sessionFactory” factory-method=”getEntityManagerFactoryInterface” factory-bean=”jpaVendorAdptr” />

    <!–transaction manager–>
    <bean id=”txManager” class=”org.springframework.orm.jpa.JpaTransactionManager”>
    <property name=”entityManagerFactory” ref=”entityManagerFactory” />
    </bean>

    Spring config for JBPM integration:
    <bean id=”jbpmConfiguration” class=”org.jbpm.pvm.internal.cfg.SpringConfiguration”>
    <constructor-arg value=”jbpm.cfg.xml” />
    <property name=”sessionFactory” ref=”sessionFactory” />
    </bean>

    <bean id=”processEngine” factory-bean=”jbpmConfiguration” factory-method=”buildProcessEngine” />

    <bean id=”repositoryService” factory-bean=”processEngine” factory-method=”getRepositoryService” />

    <bean id=”executionService” factory-bean=”processEngine” factory-method=”getExecutionService” />

  25. kwangcheol says

    Hi andries.
    Thanks for your demo example.

    I have faced the problem in using it.

    Almost all of it are working fine.
    But when i try to undeploy definition by repositoryService.deleteDeploymentCascade(deploymentId) method,
    Bellow error was caused.
    I need your advice.
    Your help will be appreciate and helpfull me.

    Thanks,
    Kwangcheol

    10:01:53,371 FIN | [DeleteDeploymentCmd] deleting deployment 19
    Hibernate: select deployment0_.DBID_ as DBID1_19_0_, deployment0_.NAME_ as NAME2_19_0_, deployment0_.TIMESTAMP_ as TIMESTAMP3_19_0_, deployment0_.STATE_ as STATE4_19_0_ from JBPM4_DEPLOYMENT deployment0_ where deployment0_.DBID_=?
    Hibernate: select resources0_.DEPLOYMENT_ as DEPLOYMENT4_1_, resources0_.DBID_ as DBID1_1_, resources0_.NAME_ as NAME5_1_, resources0_.DBID_ as DBID1_23_0_, resources0_.DBVERSION_ as DBVERSION2_23_0_, resources0_.BLOB_VALUE_ as BLOB3_23_0_ from JBPM4_LOB resources0_ where resources0_.DEPLOYMENT_=?
    Hibernate: select objectprop0_.DEPLOYMENT_ as DEPLOYMENT2_1_, objectprop0_.DBID_ as DBID1_1_, objectprop0_.DBID_ as DBID1_20_0_, objectprop0_.DEPLOYMENT_ as DEPLOYMENT2_20_0_, objectprop0_.OBJNAME_ as OBJNAME3_20_0_, objectprop0_.KEY_ as KEY4_20_0_, objectprop0_.STRINGVAL_ as STRINGVAL5_20_0_, objectprop0_.LONGVAL_ as LONGVAL6_20_0_ from JBPM4_DEPLOYPROP objectprop0_ where objectprop0_.DEPLOYMENT_=?
    ### EXCEPTION ###########################################
    10:01:53,387 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd@a37c6a
    java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:396)
    at org.jbpm.pvm.internal.repository.RepositoryCacheImpl.set(RepositoryCacheImpl.java:45)
    at org.jbpm.pvm.internal.cmd.DeleteDeploymentCmd.execute(DeleteDeploymentCmd.java:92)
    at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
    at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
    at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
    at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
    at org.jbpm.pvm.internal.repository.RepositoryServiceImpl.deleteDeployment(RepositoryServiceImpl.java:66)
    at com.tfsm.b3mb.bpm.business.UndeployServiceImpl.deleteDeployment(UndeployServiceImpl.java:30)
    at com.tfsm.b3mb.bpm.business.test.UndeployServiceTest.testDeleteDeployment(UndeployServiceTest.java:97)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    ### EXCEPTION ###########################################

  26. Caine says

    Partho,

    Did you ever find a solution to your problem integrating with JPA? I have tried to get this working on Tomcat with the JPA Adapter also but to no avail. My configuration is almost identical to yours.

    If anyone has any ideas on how to get this working or where to look I would greatly appreciate it.

  27. Andries Inzé says

    I’ve yet found time to do it.
    Best bet is to post it on the forums…

  28. Wang says

    Hi,
    I did as said by you, but got the following error, can someone help me?
    I use Tomcat6 and jBPM4 with JSF1.2
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘processEngine’ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: No matching factory method found: factory bean ‘jbpmConfiguration’; factory method ‘buildProcessEngine’
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:373)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:936)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:851)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:251)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:190)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1247)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:377)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:613)

  29. Faisal Basra says

    Thanks very much for such a nice guide for integration jbpm4 with spring, hibernate and jsf + richfaces…

    Would you like to share the source too, of the war example, so we can extend it easily….

    Thanks in advance.

  30. Andries Inzé says

    You can find the source at http://anonsvn.jboss.org/repos/jbpm/projects/demos/

  31. Faisal Basra says

    Andries Inzé, I have one more question…

    our application is already spring + hibernate based, I am troubling to integrate your supposed jbpm spring integration method.

    We already have, applicatonContext.cfg.xml, hibernate.cfg.xml & spring have a named session factory plus transaction manger & its configured with MS MSQL server.

    Now, I have setup MySQL database for jbpm, now what should config files & architecture should have?

    Looking, for your expert advice in this regard, if you can describe it in details I will be more thankful to you.

  32. Larry H says

    How does one actually build and deploy from your sources? I see that a partial unexploded hierarchy is created in the WebRoot area (no libraries), that there is no war built for deploy and that there really isn’t a deploy dependent target when I do a maven install.

    So, how do you go about getting your code to run under Jetty or Tomcat or whatever your app server is? I suspect some others would like to know, too. Thanks.

  33. Larry H says

    Andre:

    I am running into many problems when building your jBPM4 example from source, in that the maven dependencies are broken or missing, especially the 4.0.0-SNAPSHOT ones. Could you update your build scripts or provide an updated example that can build & run?. Thanks.

  34. Andries Inzé says

    Larry,

    In later posts I reference to https://anonsvn.jboss.org/repos/jbpm/projects/demos/
    These are up2date and contain numerous changes due to a changing API.

    Regards

  35. Larry H says

    Andre:

    Thanks for the reply. I had no idea what your 01/09/2009 reference to a “jbpm svn” was, so now I know – thanks. I’m running into a similar build problem with the richfaces-spring-jbpm4 project, which is based on jBPM4.1-SNAPSHOT and (I believe) assumes you’ve downloaded the correct bundle and repository-ed it already with maven. So, rather than attempt to find the jBPM4.1 bundle you’ve built with, can you provide a jBoss link to the package I would need to build this project? Thanks.

  36. Larry H says

    Andre & all:

    Apparently the jBPM4.1-SNAPSHOT is no more, but I tried the jbpm-jpdl-4.1 library resources and now I’m able to run your test application in the mock environment and in my Tomcat 6.0.

    Change your maven build file accordingly with whatever’s current @ http://repository.jboss.com/maven2/org/jbpm/jbpm4/jbpm-jpdl/4.1/ ; the maven repo for jBPM does ‘contain numerous changes due to a changing API’ and you have to change with it. So, I verified it’s working for me right now, but who knows what might happen after midnight tonight.

    Like Andre pointed out before,

  37. Apollo11 says

    Andries,

    You example was excellent. It works fine if the jBPM with Spring (I’m currently using Spring 3.0 RC1) Integration in single transaction. However, it fails if there is a nested transaction round the jBPM. For example, I have a method like this:
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public Object execute(Environment environment) throws Exception {
    environment.getProcessService().startProcessInstanceByKey(
    “MY-Workflow”, variables, workflowKey);

    return environment.getService()
    .saveWorkflowKey(date, workflowKey);
    }

    1. after excuted environment.getProcessService().startProcessInstanceByKey(“MY-Workflow”, variables, workflowKey) statement, the workflow(processInstance) was succeefully saved and “commited” to the database.
    2. environment.getService().saveWorkflowKey(date, workflowKey) throws exception, the ProcessInstance was never been rollback.

    here was config I had:

    I traced the code into the SpringTransactionInterceptor code, , it sets the userCurrent = true and executed if (useCurrent) {
    template.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
    }
    So the transaction PROPAGATION is MANDATORY.

    when executign the statment StandardTransaction standardTransaction = environment.get(StandardTransaction.class), the enviroment returns a valid StandardTransaction, and later, the standardTransaction.complete() and commit the transaction. According to the “spring-transaction-interceptor: The standard-transaction-interceptor will start and commit transactions. Instead, we want jbpm to reuse an existing transaction. The current=true forces the interceptor to check if a transaction already exists. It will crash else. On current=false, a new transaction will be created.”

    The StandardTransaction should not be created, do I miss anything here?
    I’m using jBPM 4.1, Srping 3.0 RC1, SQL Server 2005 and JPA.

  38. Apollo11 says

    here was the config

  39. Andries Inzé says

    Apollo11,

    Can’t get the XML code to be visible. I FAIL at PHP :D

    Anyway, you could mail me your snippets @ andries[AT]inze.be

    Could it be you have a transaction defined in your transaction-context? I would leave it out.

  40. Apollo11 says

    Just sent your all the configs.

  41. Rocker Rocker says

    Thanks , this was a good start for me . I have Jboss and using this blog , i have setup a sample process using Spring & Hibernate. I had to cleanup lib folders and add only few jars as it caused deployment issues (ClassCastException) with Jboss 5.0.1GA server (already installed JSF . EL jars) – may be due to version differences.
    Anyways, now that i have some process up and running. is there a way to have more controls (deploy. check status. user specific task etc ) as shown by some screen shots in JBOSS examples (jboss-console).

    Rather is there a way to use setup as base and deploy jboss-console to control deployment , check activity status etc. as i dont want to write those things again.

    I do want to use this code structure for my process ?

  42. Anonymous says

    That does not work in jbpm-4.3

  43. Andries Inzé says

    True, Tom has refactored some definitions in Spring 4.3. You’ll have to check the dev guide.

  44. rams says

    Hi Andries,

    I have been using jbpm4 for sometime…all these days i had datasource properties (like url, username, passwd) read from property file. As soon as i changed datasource to jndi one it fails with below error whenever i call any create/update operations on jbpm.

    Pre-bound JDBC Connection found! HibernateTransactionManager does not support running within DataSourceTransactionManager if told to manage the DataSource itself. It is recommended to use a single HibernateTransactionManager for all transactions on a single DataSource, no matter whether Hibernate or JDBC access.

    Env: Jboss 5.1.0.GA, Oracle 10g, Jbpm 4.0, Spring 2.5.6, Hibernate

  45. Andries Inzé says

    rams,

    You’ll get more help on the jBPM forums

  46. ebi says

    i need a userName and password for checkout svn
    ?

  47. Andries Inzé says

    You need the anonymous SVN.https://anonsvn.jboss.org/repos/jbpm

  48. Jhon says

    Hi Andries,
    I have some problems with running your sample. I checked out the project and downloaded maven jbpm dependencies(extracted to .m2/repository/org/jbpm), but when I typed mvn jetty:run, it said
    “1) org.jbpm.jbpm4:jbpm-jpdl:jar:4.0-SNAPSHOT

    Try downloading the file manually from the project website.

    Then, install it using the command:
    mvn install:install-file -DgroupId=org.jbpm.jbpm4 -DartifactId=jbpm-jpdl -Dversion=4.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file

    Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=org.jbpm.jbpm4 -DartifactId=jbpm-jpdl -Dversion=4.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

    Path to dependency:
    1) be.inze.spring.demo:jbpm4-spring:war:0.2-SNAPSHOT
    2) org.jbpm.jbpm4:jbpm-jpdl:jar:4.0-SNAPSHOT

    ———-
    1 required artifact is missing.

    for artifact:
    be.inze.spring.demo:jbpm4-spring:war:0.2-SNAPSHOT

    from the specified remote repositories:”…., I changed the pom.xml and made jbpm version 4.0.0 instead of 4.0 but this time it said
    “[ERROR] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Compilation failure

    C:\dev\projects\workspace\Spring-Jbpm-2\src\main\java\be\inze\spring\demo\service\impl\DeployServiceImpl.java:[7,19] cannot find symbol
    symbol : class NewDeployment
    location: package org.jbpm.api

    C:\dev\projects\workspace\Spring-Jbpm-2\src\main\java\be\inze\spring\demo\service\impl\ProcessInformationServiceImpl.java:[29,59] incompatible types
    found : java.util.List
    required: java.util.List

    C:\dev\projects\workspace\Spring-Jbpm-2\src\main\java\be\inze\spring\demo\service\impl\SimpleProcessServiceImpl.java:[22,57] cannot find symbol
    symbol : method processDefinitionKey(java.lang.String)
    location: interface org.jbpm.api.ProcessDefinitionQuery

    C:\dev\projects\workspace\Spring-Jbpm-2\src\main\java\be\inze\spring\demo\service\impl\DeployServiceImpl.java:[23,2] cannot find symbol
    symbol : class NewDeployment
    location: class be.inze.spring.demo.service.impl.DeployServiceImpl”

    Could you help, please??



Some HTML is OK

or, reply to this post via trackback.