`

JBPM 与 Spring 结合

    博客分类:
  • Java
阅读更多

今天尝试了将jbpm和spring进行结合,主要参考http://betafox.iteye.com/blog/177649来进行。

版本:

jbpm          3.1.4

struts2       2.0.11

spring        2.5.1

hibernate   3.2.5.ga

配置文件如下:

<?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:util="http://www.springframework.org/schema/util"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:lang="http://www.springframework.org/schema/lang"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd"
	default-autowire="byName">

	<bean id="workflow1"
		class="org.springmodules.workflow.jbpm31.definition.ProcessDefinitionFactoryBean">
		<property name="definitionLocation"
			value="classpath:jbpm/processes/processdefinition.xml" />
	</bean>

	<!-- jBPM configuration-->
	<bean id="jbpmConfiguration"
		class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
		<property name="sessionFactory" ref="sessionFactory" />
		<property name="configuration" value="classpath:jbpm.cfg.xml" />

		<property name="processDefinitions">
			<list>
				<ref local="workflow1" />
			</list>
		</property>
		<!-- 
			<property name="createSchema" value="true" />
			<property name="dropSchema" value="true" />
		-->
	</bean>

	<!-- jBPM template -->
	<bean id="jbpmTemplate"
		class="org.springmodules.workflow.jbpm31.JbpmTemplate">
		<constructor-arg index="0" ref="jbpmConfiguration" />
		<constructor-arg index="1" ref="workflow1" />
	</bean>

</beans>

 在casspath下添加了jbpm.cfg.xml,内容是从default.jbpm.cfg.xml中复制过来的:

<jbpm-configuration>

	<jbpm-context name="default.jbpm.context">

		<service name="persistence"
			factory="org.jbpm.persistence.db.DbPersistenceServiceFactory" />
		<service name="message"
			factory="org.jbpm.msg.db.DbMessageServiceFactory" />
		<service name="scheduler"
			factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
		<service name="logging"
			factory="org.jbpm.logging.db.DbLoggingServiceFactory" />
		<service name="authentication"
			factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
	</jbpm-context>


	<!-- 不再使用<string name="resource.hibernate.cfg.xml" value="hibernate.cfg.xml" />-->
	<string name="resource.business.calendar"
		value="org/jbpm/calendar/jbpm.business.calendar.properties" />
	<string name="resource.default.modules"
		value="org/jbpm/graph/def/jbpm.default.modules.properties" />
	<string name="resource.converter"
		value="org/jbpm/db/hibernate/jbpm.converter.properties" />
	<string name="resource.action.types"
		value="org/jbpm/graph/action/action.types.xml" />
	<string name="resource.node.types"
		value="org/jbpm/graph/node/node.types.xml" />
	<string name="resource.parsers"
		value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
	<string name="resource.varmapping"
		value="org/jbpm/context/exe/jbpm.varmapping.xml" />

</jbpm-configuration>
 

在配置过程中也遇到了一些问题。

问题一:系统报找不到 default.jbpm.context。

解决方法:在自己的jbpm.cfg.xml中设置

jbpm-context name="default.jbpm.context"

问题二:系统报找不到hibernate.cfg.xml。

解决方法:我的系统里hibernate配置放在spring的配置文件里,没有使用hibernate.cfg.xml。跟踪DbPersistenceServiceFactory和LocalJbpmConfigurationFactoryBean.afterPropertiesSet发现问题出在jbpmContext构建时需要获取持久层,如果sessionFactory存在则不会去读取hibernate.cfg.xml,除了在配置jbpmConfiguration时要设置sessionFactory外,如果jbpm的数据库表已经存在,则不要设置createSchema和dropSchema否则会报错。按上面的配置文件设置后,不会再去读取hibernate.cfg.xml,可以注释掉jbpm.cfg.xml中的resource.hibernate.cfg.xml。

注意:如果使用这种配置方式,省略了hibernate.cfg.xml文件,但如果调用jbpmConfiguration.createSchema();jbpmConfiguration.dropSchema();等方法还是会出错,跟踪源码可以发现这些方法都会调用DbPersistenceServiceFactory.getConfiguration()方法,这个方法会去读取hibernate.cfg.xml。我们可以使用jbpm-db\build\mysql\scripts\下的脚本手工创建或删除数据库,这在做单元测试时稍显麻烦。

问题三:jbpm-identity中有User.hbm.xml,这个名称与我系统中原有的User.hbml.xml冲突,尽管他们不在同一个包中,但还是产生了冲突。只能调整一下自己的代码了。

spring配置文件中配置流程定义的xml有些多余,反而使系统在启动的时候更新数据库里的流程定义。完全可以将流程部署到数据库。JbpmTemplate有无参数的构造器,可以不使用构造器注入,只需要在spring配置文件中注它的jbpmConfiguration属性就可以了。

 

另,没有添加参考文章里说的过滤器,暂时没发现问题。

分享到:
评论
1 楼 jinguizi 2008-08-04  
sessionFactory怎么配的?

相关推荐

    JBPM3.2与Spring结合时任务调度的实现.doc

    JBPM3.2与Spring结合时任务调度的实现.doc

    工作流(JBPM)一些有用资料整合

    含有JBPM一些有用资料:JBPM与SPRING事务整合之深度历险;流程引擎内核设计思想及构架;JBPM 与 Spring 结合

    spring整合JPBM3.2

    Jbpm3.1.x的时候,如果我们要实现Jbpm与Spring结合使用需要借助于SpringModule中spring-modules-jbpm31.jar来实现。目前Jbpm的最新版本是3.2.1,对于这一版本如果我们要实现其与Spring结合使用,同样我们也可以借助...

    流程引擎jBPM demo及Spring Boot示例

    流程引擎jBPM基于jboss kie 项目使用的代码示例,包括基本jBPM基本demo,与spring boot 结合使用等,简单易入门

    jbpm7示例(jbpm-7.3.0.Final-examples)

    jBPM可以与Drools项目相结合,以支持将这些范例集成到一起的统一环境,您可以将业务逻辑作为过程,规则和事件的组合进行建模。 工作是MAVEN+eclipse jBPM jars也可以在中央maven仓库中使用 (也可以在JBoss maven...

    JBPM5 用户指南

    14.1.3测试与外部服务的结合 93 14.1.4 配置持久化 94 14.2 调试 94 14.2.1 流程实例视图 95 14.2.2 人工任务视图 96 14.2.3 核查视图 96 第十五章 流程知识库 97 第十六章 业务活动监视器 99 16.1 报告 99 16.2 ...

    jsp jbpm 做的一个小实例

    这是我自己在这里几天学习jbpm做的一个小实例,完全用JSP+JBPM,接下来我会和spring结合在一起,希望在学习的你有帮助

    JBPM5权威指南

    14.1.3测试与外部服务的结合 93 14.1.4 配置持久化 94 14.2 调试 94 14.2.1 流程实例视图 95 14.2.2 人工任务视图 96 14.2.3 核查视图 96 第十五章 流程知识库 97 第十六章 业务活动监视器 99 16.1 报告 99 16.2 ...

    JBPM4工作流应用开始指南.rar

    包括jBPM4扩展研发先决条件、深入jPDL和jBPM Service API、升级jBPM3到jBPM4、流程虚拟机原理、jBPM4的设计思想、随需而配jBPM4、异步工作执行器、深入jBPM4电子邮件支持、系统日志、jBPM4与Spring框架集成、jBPM4与...

    基于jbpm与activiti的工作流平台技术架构介绍

    系统的安全管理由Spring Security 3提供配置及管理,非常容易与第三方的用户或认证平台进行整合,如与CAS服务器作统一认证,只需要加上新的配置模块即可实现,不影响系统现有的功能模块。大大满足了各种不同系统的...

    jBPM5 用户指南-中文

    14.1.3测试与外部服务的结合 99 14.1.4 配置持久化 100 14.2 调试 100 14.2.1 流程实例视图 101 14.2.2 人工任务视图 102 14.2.3 核查视图 102 第十五章 流程知识库 103 第十六章 业务活动监视器 105 16.1 报告 105 ...

    jBPM-Springboot-Integration

    StringBoot + Mysql5.7.18项目版本SpringBoot 2.0.2.RELEASEjBPM7.7.0 Final项目中已包含数据库创建脚本/doc/jbpm.sql(原始) /doc/jbpm20180514.sql(结合业务生成)目录结构 /doc/jbpm.sql 脚本 /resources/...

    maven-framework-project:基于maven的多框架和多视图融合技术(Struts1,Struts2,Spring,SpringMVC,Hibernate,Ibatis,MyBatis,Spring Data JPA,DWR)

    该项目后期会陆续集成一些好的框架进来一些说Spring Web Flow,Jbpm,WebService,Compass,Solr,nutch等。总之是一个综合性的项目。该项目不处理业务,主要是把当前自己工作中用纯粹是一个jee框架的糅合,主要是...

    javaeye热点阅读

    1.2 jbpm3与jbpm4实现对比 1.3 Java、PHPRPC、Hessian、Burlap、AMF3、XML 序列化的效率对比1.4 Effective Java Second Edition中文版已出版1.5 国内开源工作流 Fire Workflow 出炉了 1.6 Word/Excel/PDF文件转换成...

    工作流引擎在教务管理系统开发中的应用

    随着网络技术的发展,传统的数字化办公已经越来越不能满足企业发展的需求,一个可以给企业信息化管理带来高效的软件是...重点研究了JBPM 工作流引擎嵌入教务管理系统时与spring 无缝结合、数据一致性、JBPM 封装等问题

    论文研究-通信账户运营管理系统中流程模块的设计与实现 .pdf

    通信账户运营管理系统中流程模块的设计与实现,吴恩珍,袁超伟,根据通信账户管理系统的实际业务需求,为了保证流程的稳定和易于管理,本文以Jboss JBPM4.4为流程引擎,结合spring struts MVC框架的特点,

    基于工作流的高校办公自动化系统的设计与实现-毕业设计论文

    系统采用B/S架构,基于Eclipse平台开发,使用了Microsoft SQL Server2000数据库系统,并结合SSH(Struts+Spring+Hibernate)技术完成。其中公文管理部分使用了工作流技术,采用JBOSS JBPM作为工作流管理系统,完成公文...

    Joffice2.1操作手册

    它以基于流行的JEE开源技术整合,以JBPM4.4流程引擎为基础,采用了WebService、XML、J2EE、Spring组件的灵活配置,并且与Microsoft Office实现了有机整合。完善了用户管理和安全的权限管理,支持POP3/POP3,SMTP/...

    毕业设计基于JAVA的springboot班级综合测评管理系统-1(源代码+说明)

    本系统主要使用了Java技术Springboot框架技术,结合JBPM工作流引擎以及功能强大的MySQL数据库管理工具。系统实现了个人中心、学生管理、教师管理、班级管理、综合测评管理等功能的管理,完成了系统设计任务的所有...

    毕业设计基于JAVA的springboot班级综合测评管理系统(论文+PPT)

    本系统主要使用了Java技术Springboot框架技术,结合JBPM工作流引擎以及功能强大的MySQL数据库管理工具。系统实现了个人中心、学生管理、教师管理、班级管理、综合测评管理等功能的管理,完成了系统设计任务的所有...

Global site tag (gtag.js) - Google Analytics