JBPM(四)—SSH框架整合JBPM详解编程语言

jar包引入
如果没有使用maven,为防止jar包冲突,需要将JBPM中多余的jar包删除,如:
cglib.jar
commons-collections.jar
commons-logging.jar
freemarker.jar
hibernate-core.jar
hsqldb.jar
javassist.jar
jta.jar
junit.jar
log4j.jar
mail.jar
mysql-connector-java.jar
等。

如果使用maven坐标导入jar包
pom坐标:

<repositories> 
        <!--JBPM依赖包 maven2资源库 --> 
        <repository> 
            <id>Jboss-JBPM-Repositories</id> 
            <name>JbossJBPM</name> 
            <url>https://repository.jboss.org/nexus/content/repositories/releases</url> 
        </repository> 
</repositories> 
 
<!--JBPM4.4 --> 
        <dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-api</artifactId> 
            <version>4.4</version> 
        </dependency> 
        <dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-jpdl</artifactId> 
            <version>4.4</version> 
        </dependency> 
        <dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-pvm</artifactId> 
            <version>4.4</version> 
        </dependency> 
        <dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-log</artifactId> 
            <version>4.4</version> 
        </dependency> 
        <dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-bpmn</artifactId> 
            <version>4.4</version> 
        </dependency> 

配置文件整合

将JBPM解压目录下examples/src/jbpm.cfg.xml 复制到resources
用<import resource=”jbpm.tx.spring.cfg.xml” />替换掉jbpm.cfg.xml 文件中的
<import resource=”jbpm.tx.hibernate.cfg.xml” />

建立JBPM18张表,在spring配置文件 applicationContext-common.xml 引入 hbm

<!-- 引入 jbpm 配置文件  --> 
        <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>

修改 mysql方言 : org.hibernate.dialect.MySQL5InnoDBDialect

在spring配置文件中配置processEngine

<!-- jbpm提供工具类,获得流程引擎 --> 
    <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" />

整合常见错误:
1.发布流程时报Caused by: java.lang.ClassNotFoundException:
javax.mail.Message$RecipientType
解决方式:JBPM 运行,需要依赖 javamail的 jar 包

        <!-- javamail --> 
        <dependency> 
            <groupId>javax.mail</groupId> 
            <artifactId>mail</artifactId> 
            <version>1.4</version> 
        </dependency> 

2.将JBPM整合后项目,在tomcat运行起来报javax.servlet.ServletException: java.lang.LinkageError: loader constraint violation: when resolving interface method “javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;” the class loader (instance of org/apache/jasper/servlet/JasperLoader) of the current class, org/apache/jsp/index_jsp, and the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature

原因: jar包冲突
Juel-api.jar 和 tomcat中el-api.jar 冲突

如果是外部Tomcat,解决方法: 将juel三个jar包放入tomcat /lib 下替换 el-api.jar
删除原来项目中 juel三个jar 包

使用maven内置Tomcat,解决方法:
将工程内部 juel三个jar 包 设置 provided

<dependencyManagement> 
    <dependencies> 
        <dependency> 
            <groupId>juel</groupId> 
            <artifactId>juel-api</artifactId> 
            <version>2.2.1</version> 
            <scope>provided</scope> 
        </dependency> 
        <dependency> 
            <groupId>juel</groupId> 
            <artifactId>juel-impl</artifactId> 
            <version>2.2.1</version> 
            <scope>provided</scope> 
        </dependency> 
        <dependency> 
            <groupId>juel</groupId> 
            <artifactId>juel-engine</artifactId> 
            <version>2.1.0</version> 
            <scope>provided</scope> 
        </dependency> 
    </dependencies> 

在内置tomcat中 引入juel的jar 包

                <!-- 引入juel的jar包 --> 
                <dependencies> 
                    <dependency> 
                        <groupId>de.odysseus.juel</groupId> 
                        <artifactId>juel-api</artifactId> 
                        <version>2.2.6</version> 
                    </dependency> 
                    <dependency> 
                        <groupId>de.odysseus.juel</groupId> 
                        <artifactId>juel-impl</artifactId> 
                        <version>2.2.6</version> 
                    </dependency> 
                </dependencies> 

3.slf4j 日志冲突错误 ,slf4j-log4j 和 slf4j-jdk 冲突

<dependency> 
            <groupId>org.jbpm.jbpm4</groupId> 
            <artifactId>jbpm-pvm</artifactId> 
            <version>4.4</version> 
            <exclusions> 
                <exclusion> 
                    <artifactId>slf4j-jdk14</artifactId> 
                    <groupId>org.slf4j</groupId> 
                </exclusion> 
            </exclusions> 
        </dependency> 

pom.xml示例:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.my.bos</groupId> 
<artifactId>mavenbos</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 
<name>mavenbos</name> 
<repositories> 
<!--JBPM依赖包 maven2资源库 --> 
<repository> 
<id>Jboss-JBPM-Repositories</id> 
<name>JbossJBPM</name> 
<url>https://repository.jboss.org/nexus/content/repositories/releases</url> 
</repository> 
</repositories> 
<dependencies> 
<!-- spring 3.2 --> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-context</artifactId> 
<version>3.2.0.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-orm</artifactId> 
<version>3.2.0.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-aspects</artifactId> 
<version>3.2.0.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-web</artifactId> 
<version>3.2.0.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-test</artifactId> 
<version>3.2.0.RELEASE</version> 
</dependency> 
<!-- Struts 2 --> 
<dependency> 
<groupId>org.apache.struts</groupId> 
<artifactId>struts2-core</artifactId> 
<version>2.3.7</version> 
</dependency> 
<dependency> 
<groupId>org.apache.struts</groupId> 
<artifactId>struts2-json-plugin</artifactId> 
<version>2.3.7</version> 
</dependency> 
<dependency> 
<groupId>org.apache.struts</groupId> 
<artifactId>struts2-spring-plugin</artifactId> 
<version>2.3.7</version> 
</dependency> 
<!-- hibernate 3.6 --> 
<dependency> 
<groupId>org.hibernate</groupId> 
<artifactId>hibernate-core</artifactId> 
<version>3.6.10.Final</version> 
</dependency> 
<!-- JPA --> 
<dependency> 
<groupId>org.hibernate.javax.persistence</groupId> 
<artifactId>hibernate-jpa-2.0-api</artifactId> 
<version>1.0.1.Final</version> 
</dependency> 
<!-- Servlet & Jsp --> 
<dependency> 
<groupId>javax.servlet</groupId> 
<artifactId>servlet-api</artifactId> 
<version>2.5</version> 
<scope>provided</scope> <!-- 这个jar包只参与本地编译,不参与打包和发布 --> 
</dependency> 
<dependency> 
<groupId>javax.servlet</groupId> 
<artifactId>jsp-api</artifactId> 
<version>2.0</version> 
<scope>provided</scope> 
</dependency> 
<!-- log4j --> 
<dependency> 
<groupId>org.slf4j</groupId> 
<artifactId>slf4j-log4j12</artifactId> 
<version>1.7.2</version> 
</dependency> 
<dependency> 
<groupId>log4j</groupId> 
<artifactId>log4j</artifactId> 
<version>1.2.16</version> 
</dependency> 
<!-- C3P0 --> 
<dependency> 
<groupId>c3p0</groupId> 
<artifactId>c3p0</artifactId> 
<version>0.9.1.2</version> 
</dependency> 
<!-- mysql --> 
<dependency> 
<groupId>mysql</groupId> 
<artifactId>mysql-connector-java</artifactId> 
<version>5.1.6</version> 
</dependency> 
<!-- junit --> 
<dependency> 
<groupId>junit</groupId> 
<artifactId>junit</artifactId> 
<version>4.9</version> 
<scope>test</scope> <!-- 这个jar包只参与测试 --> 
</dependency> 
<!-- pinyin4j --> 
<dependency> 
<groupId>pinyin4j</groupId> 
<artifactId>pinyin4j</artifactId> 
<version>1.0</version> 
<systemPath>D:/work/javaee20130711/mavenbos/src/main/webapp/WEB-INF/lib/pinyin4j-2.5.0.jar</systemPath> 
<scope>system</scope> 
</dependency> 
<!-- POI --> 
<dependency> 
<groupId>org.apache.poi</groupId> 
<artifactId>poi</artifactId> 
<version>3.9</version> 
</dependency> 
<!-- Hessian --> 
<dependency> 
<groupId>com.caucho</groupId> 
<artifactId>hessian</artifactId> 
<version>4.0.33</version> 
</dependency> 
<!-- JBPM4.4 --> 
<dependency> 
<groupId>org.jbpm.jbpm4</groupId> 
<artifactId>jbpm-api</artifactId> 
<version>4.4</version> 
</dependency> 
<dependency> 
<groupId>org.jbpm.jbpm4</groupId> 
<artifactId>jbpm-jpdl</artifactId> 
<version>4.4</version> 
</dependency> 
<dependency> 
<groupId>org.jbpm.jbpm4</groupId> 
<artifactId>jbpm-pvm</artifactId> 
<version>4.4</version> 
<exclusions> 
<exclusion> 
<artifactId>slf4j-jdk14</artifactId> 
<groupId>org.slf4j</groupId> 
</exclusion> 
</exclusions> 
</dependency> 
<dependency> 
<groupId>org.jbpm.jbpm4</groupId> 
<artifactId>jbpm-log</artifactId> 
<version>4.4</version> 
</dependency> 
<dependency> 
<groupId>org.jbpm.jbpm4</groupId> 
<artifactId>jbpm-bpmn</artifactId> 
<version>4.4</version> 
</dependency> 
<!-- javamail --> 
<dependency> 
<groupId>javax.mail</groupId> 
<artifactId>mail</artifactId> 
<version>1.4</version> 
</dependency> 
</dependencies> 
<build> 
<!-- 指定打war包命名 --> 
<finalName>mavenbos</finalName> 
<plugins> 
<plugin> 
<artifactId>maven-compiler-plugin</artifactId> 
<configuration> 
<source>1.6</source> 
<target>1.6</target> 
</configuration> 
</plugin> 
<!-- 早期 tomcat-maven-plugin插件 --> 
<plugin> 
<groupId>org.codehaus.mojo</groupId> 
<artifactId>tomcat-maven-plugin</artifactId> 
<version>1.1</version> 
<configuration> 
<!-- 改变内嵌tomcat 运行端口 --> 
<port>9090</port> 
<!-- 发布到外面tomcat 自动 --> 
<url>http://localhost:8080/manager/text</url> 
<server>myserver</server> 
</configuration> 
<!-- 引入juel的jar包 --> 
<dependencies> 
<dependency> 
<groupId>de.odysseus.juel</groupId> 
<artifactId>juel-api</artifactId> 
<version>2.2.6</version> 
</dependency> 
<dependency> 
<groupId>de.odysseus.juel</groupId> 
<artifactId>juel-impl</artifactId> 
<version>2.2.6</version> 
</dependency> 
</dependencies> 
</plugin> 
</plugins> 
</build> 
<dependencyManagement> 
<dependencies> 
<dependency> 
<groupId>juel</groupId> 
<artifactId>juel-api</artifactId> 
<version>2.2.1</version> 
<scope>provided</scope> 
</dependency> 
<dependency> 
<groupId>juel</groupId> 
<artifactId>juel-impl</artifactId> 
<version>2.2.1</version> 
<scope>provided</scope> 
</dependency> 
<dependency> 
<groupId>juel</groupId> 
<artifactId>juel-engine</artifactId> 
<version>2.1.0</version> 
<scope>provided</scope> 
</dependency> 
</dependencies> 
</dependencyManagement> 
</project>

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/12050.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论