`
kxmd2008
  • 浏览: 4449 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

JBPM4.2与spring集成

阅读更多

修改jbpm提供的spring.jbpm.cfg.xml,application.xml,jbpm.tx.spring.cfg.xml,jbpm.tx.hibernate.cfg.xml来做spring与jbpm的集成,
首先修改jbpm.tx.spring.cfg.xml的名字为jbpm42.spring.cfg.xml讲内容改为

<jbpm-configuration>

	<process-engine-context>
<!--结合jbpm.tx.hibernate.xml-->
		<command-service name="txRequiredCommandService">
			<skip-interceptor />
			<retry-interceptor />
			<environment-interceptor />
<!--使用spring管理transaction-->
			<spring-transaction-interceptor />
		</command-service>

		<command-service name="newTxRequiredCommandService">
			<retry-interceptor />
			<environment-interceptor policy="requiresNew" />
			<spring-transaction-interceptor current="true"/>
		</command-service>
<!--下面为jbpm.default.cfg.xml中的配置,由于jbpm.default.cfg.xml中需要引入jbpm.hibernate.cfg.xml,所以将配置改写到这里,或改jbpm.hibernate.cfg.xml源码,将引入jbpm.hibernate.cfg.xml注掉-->
		<repository-service />
		<repository-cache />
		<execution-service />
		<history-service />
		<management-service />
		<identity-service />
		<task-service />

		<object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
			<field name="commandService">
				<ref object="newTxRequiredCommandService" />
			</field>
		</object>

		<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer"
			init="eager" />

		<script-manager default-expression-language="juel"
			default-script-language="juel">
			<script-language name="juel"
				factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
		</script-manager>

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

		<address-resolver />

	</process-engine-context>

	<transaction-context>
<!--强制从当前线程中获取, 删掉了原来的<transaction />-->
		<hibernate-session factory="hibernateSessionFactory"  current="true" />
<!--jbpm.default.cfg.xml中的配置-->
		<repository-session />
    	        <db-session />
   		<message-session />
   	 	<timer-session />
   	 	<history-session />
	</transaction-context>
</jbpm-configuration>

接下来将spring.jbpm.cfg.xml改为

 

<jbpm-configuration>

  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="spring/jbpm42.spring.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" />-->

</jbpm-configuration>

 最后将applicationContext.xml改为

 

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

	<context:property-placeholder location="classpath:jdbc.properties" />


	<!-- Configure DB data source -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		destroy-method="close">
		<property name="driverClass">
			<value>${jdbc.driver}</value>
		</property>
		<property name="jdbcUrl">
			<value>${jdbc.url}</value>
		</property>
		<property name="user">
			<value>${jdbc.username}</value>
		</property>
		<property name="password">
			<value>${jdbc.password}</value>
		</property>
		<!--
			<property name="maxActive" value="2" /> <property name="maxIdle"
			value="2" /> <property name="maxWait" value="10000" />
		-->
		<!--连接池中保留的最小连接数。-->
		<property name="minPoolSize">
			<value>5</value>
		</property>
		<property name="maxPoolSize">
			<value>5000</value>
		</property>
		<property name="maxIdleTime">
			<value>60</value>
		</property>
		<property name="idleConnectionTestPeriod">
			<value>60</value>
		</property>
		<property name="acquireIncrement">
			<value>10</value>
		</property>
		<property name="checkoutTimeout">
			<value>0</value>
		</property>
	</bean>

	<!-- Configure hibernate session factory -->
	<bean id="hibernateSessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<property name="dataSource">
			<ref local="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>  
                <prop key="hibernate.cache.use_second_level_cache">true</prop>  
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>  
                <prop key="hibernate.show_sql">false</prop>  
                <prop key="hibernate.format_sql">true</prop>  
            </props>
		</property>
		<property name="mappingResources">
			<list>
				<value>jbpm.repository.hbm.xml</value>
				<value>jbpm.execution.hbm.xml</value>
				<value>jbpm.history.hbm.xml</value>
				<value>jbpm.task.hbm.xml</value>
				<value>jbpm.identity.hbm.xml</value>
			</list>
		</property>
	</bean>
	
	<!--  =========jbpm4.2 configuration=========  -->
	<bean id="jbpm4Configuration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
		<constructor-arg value="spring/spring.jbpm.cfg.xml" />
	</bean>

	<bean id="processEngine" factory-bean="jbpm4Configuration" factory-method="buildProcessEngine" />

	<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
	<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
	<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
	<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
	<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
	<!--  =========jbpm4.2 end=========  -->

	<!-- Transaction management-->
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref local="hibernateSessionFactory" />
		</property>
	</bean>

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

</beans>

 修改完成。

途中出现的错误:

exception while executing command org.jbpm.pvm.internal.cmd.DeployCmd@

java.lang.NullPointerException

开始在网上找原因说是因为少了这么两句:

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

但我是引入了jbpm.jpdl.cfg.xml的,不需要加这两句,后来跟代码发现repositorySession 为null

是由于没有加入<repository-session />所致。

 

分享到:
评论
2 楼 fengchao723 2009-12-21  
楼主你好。。我按照你的方法配置出现错误,org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpm4Configuration' defined in ServletContext resource [/WEB-INF/dataSource.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.jbpm.pvm.internal.cfg.SpringConfiguration]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.w3c.dom.Element.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object

我更换了好几个版本的Xerces和XML-APIS.JAR 都不行。从JBPM4.2包里自带的也试了。还是有这个错误。请问你做的时候出现这个错误了么。
1 楼 小开ye 2009-12-08  
谢谢了,下午试着更新了一下,无法保持的同一个事务中,呵呵。
用下面这个就好了。
<hibernate-session factory="hibernateSessionFactory" current="true" /> 

相关推荐

    jbpm4.2开发文档

    #### 五、jbpm4.2与Java Web集成 - **Spring框架集成**:利用Spring的依赖注入特性简化jbpm组件的配置。 - **Web应用示例**:提供了一个基于Tomcat的应用示例,展示了如何在Web环境中使用jbpm进行流程管理。 - **...

    jbpm 4.3 与 spring 集成 .doc

    在jbpm 4.2版本中,与Spring的集成存在一些问题,但在4.3版本中,这些问题得到了解决,使得集成过程更加顺畅。 集成的主要步骤包括: 1. **复制配置文件**:首先,你需要从jbpm 4.3安装目录的`src/cfg`子目录下,...

    jbpm4.2jar

    jbpm4.2jar是一个与Java业务流程管理(BPM)相关的库文件,它属于jbpm框架的第4.2版本。jbPM是开源的企业级BPM解决方案,它提供了全面的功能来支持工作流自动化、业务规则管理和组织内业务流程的建模、执行和监控。 ...

    Spring 3.1.x + Hibernate 4.2.x+JBPM 5.2 + Ecache例子源码

    标题中的"Spring 3.1.x + Hibernate 4.2.x + JBPM 5.2 + Ecache例子源码"代表了一个集成开发环境,其中包含了四个关键的技术组件: 1. **Spring 3.1.x**:这是一个开源的应用框架,主要用于简化Java企业级应用的...

    Spring 3.1.x + Hibernate 4.2.x+JBPM 5.2 + Ecache例子

    标题 "Spring 3.1.x + Hibernate 4.2.x + JBPM 5.2 + Ecache 例子" 涉及的是一个集成多种技术的Java应用开发示例。这个项目可能是一个完整的业务流程管理系统,它整合了Spring、Hibernate、JBPM和Ecache等关键组件。...

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

    jBPM4与Spring框架集成 296 18.1 集成的目标 297 18.2 为集成配置jBPM4 297 18.3 为集成配置Spring 299 18.4 使用 301 18.5 测试 302 18.6 小结 302 第19章 jBPM4与JBoss应用服务器集成 303 19.1 流程定义打包部署 ...

    Spring攻略(第二版 中文高清版).part1

    第6章 将Spring与其他Web框架集成 209 6.1 在一般Web应用中访问Spring 209 6.1.1 问题 209 6.1.2 解决方案 210 6.1.3 工作原理 210 6.2 在你的Servlet和过滤器中使用Spring 214 6.2.1 问题 214 6.2.2...

    Spring攻略(第二版 中文高清版).part2

    第6章 将Spring与其他Web框架集成 209 6.1 在一般Web应用中访问Spring 209 6.1.1 问题 209 6.1.2 解决方案 210 6.1.3 工作原理 210 6.2 在你的Servlet和过滤器中使用Spring 214 6.2.1 问题 214 6.2.2...

    JBoss jBPM jPDL中文指南

    - 它可以集成现有的安全框架,如Spring Security或JBoss AS的安全组件。 ##### 2.5 JBoss jBPM Job执行器 - **Job执行器** 用于调度和执行异步任务,例如定时任务或外部系统调用。 - 它支持多种类型的作业,并且...

    工作流引擎-选型 (各工作流对比)

    Camunda不仅能够与多种工作流技术兼容,还支持与其他多种工作流引擎进行集成,包括但不限于: - Active BPEL - Alfresco Activiti - Appian BPM - Bonitasoft - JBoss jBPM - IBM WPS / IBM BPM / IBM MQ Workflow /...

    Activiti6.0教程例子下载

    在编写这个Demo之前,至少要了解Activiti与Spring如何集成、XxxService各自的任务与作用,并完成上一章的Demo。 3.2. 流程文件xxx.bpmn20.xml 首先,我们就来编写这个流程的bpmn20.xml文件。 targetNamespace=...

    JBoss Seam 工作原理、seam和hibernate的范例、RESTFul的seam、seam-gen起步、seam组件、配置组件、jsf,jboss、标签、PDF、注解等等

    1.4. Seam 和jBPM:待办事项列表(todo list)示例..................................................................................................... 32 1.4.1. 理解代码....................................

Global site tag (gtag.js) - Google Analytics