使用Jbpm4.2 集成Spring 出现问题:
2009-11-12 15:49:51,640 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine' defined in file [......\WEB-INF\classes\spring\applicationContext-jbpm.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.cfg.SpringConfiguration.buildProcessEngine()] threw exception; nested exception is java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at org.jbpm.pvm.internal.cfg.ProcessEngineImpl.checkDb(ProcessEngineImpl.java:177)
userCommandService 为null
经调试发现,使用Spring后userCommandService 确实是null,
配置中缺少什么东西?未知。 文档中并无特殊说明,
4.1没有出现问题~
应该是4.2的Bug
jBPM-4.2集成Spring的方法,请参考这里:
http://www.family168.com/jbpm4/spring-jbpm42.html
jBPM-4.2默认提供的与spring整合的文件存在重大问题,使用官方推荐的配置方式根本无法启动流程引擎,需要进行如下修改:
第1步:将下面的内容保存为jbpm.tx.spring42.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?> <jbpm-configuration> <process-engine-context> <command-service name="txRequiredCommandService"> <skip-interceptor /> <retry-interceptor /> <environment-interceptor /> <spring-transaction-interceptor /> </command-service> <command-service name="newTxRequiredCommandService"> <retry-interceptor /> <environment-interceptor policy="requiresNew" /> <spring-transaction-interceptor /> </command-service> </process-engine-context> <transaction-context> <transaction /> <hibernate-session /> </transaction-context> </jbpm-configuration>
第2步:将jbpm.tx.spring42.cfg.xml放在classpath下。
第3步:修改jbpm.cfg.xml,使用jbpm.tx.spring42.cfg.xml替换默认的jbpm.tx.spring.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?> <jbpm-configuration> <import resource="jbpm.default.cfg.xml" /> <import resource="jbpm.businesscalendar.cfg.xml" /> <import resource="jbpm.tx.spring42.cfg.xml" /> <import resource="jbpm.jpdl.cfg.xml" /> <import resource="jbpm.identity.cfg.xml" /> <!-- Job executor is excluded for running the example test cases. --> <!-- To enable timers and messages in production use, this should be included. --> <!-- <import resource="jbpm.jobexecutor.cfg.xml" /> --> <import resource="jbpm.mail.templates.examples.xml" /> </jbpm-configuration>