jBPM的部署方法有多种,首先我们先将下载的jbpm- 3.0.2 .zip文件导入Eclipse中,在Eclipse的Package Explorer中单击右键->import…,在弹出的导入文件窗口中选择Archive file,next…
1〉、使用默认数据库HypersonicDB进行部署。
CVS站点连接信息如下:
Connection type: pserver
User: anonymous
Password:
Host: cvs.sourceforge.net
Port: 2401 (which is the default)
Repository path: /cvsroot/jbpm
Label: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/jbpm
用Eclipse连接之后,展开jbpm.3节点,check out最新版本的jbpm3。返回java perspective,你会发现增加了一个jbpm.3的工程。展开工程jbpm.3,修改build.properties文件:其中ant.home、jboss.home、jbpm.home改成你机器相应的目录,如我的是:
# jbpm.version only used for creating javadocs and the distribution package jbpm.version= 3.0.2
# ant.home is only used in the ant.install.libs target for copying the junit and clover libs ant.home=E:/Java/apache-ant- 1.6.5
# jbpm.home is only to allow build scripts to open the browser with the html test results jbpm.home=F:/soft/jsp/eclipse/jbpm-3.0.x
# jboss config proper only used for deployment jboss.home=E:/Java/jboss- 4.0.3 SP1 jboss.version=4.0.x jboss.source.configuration=default
# for creating the distribution jbpm.gpd.site.file=../jbpm-gpd-site- 3.0.2 .zip |
接下来在eclipse里,右击build.deploy.xml,选择RUN AS ANT BUILD,如果提示错误,检查上面的配置文件是否配置正确。此时,在JBOSS_HOME/server/目录下多了一个jbpm目录。在JBOSS_HOME/bin目录下输入run.bat -c jbpm运行JBOSS。启动完成后在浏览器里面输入http://localhost:8080/jbpm即可看到您期望的界面!
注意:jB PM3.0.2 版本的需要jboss-4.0.3SP1或以上版本才能通过。这时我们没有配置数据库,数据库用的是HSQL。
2〉、使用MySQL进行部署
以上介绍了直接使用默认的HypersonicDB数据库进行部署,下面我们换成MySql数据库来进行部署。
a) 修改build.properties文件,和上面的的相同,不再赘述。
b) 在MySql中创建数据库jbpmtest,数据库编码采用utf8,当然你也可以采用其它的编码,但连接参数请注意一下。
c) 在lib目录下新建mysql目录拷贝JDBC连接驱动mysql-connector-java- 3.1.7 -bin.jar到该目录下。
d) 修改src/config.files/hibernate.cfg.xml文件
<!-- jdbc connection properties --> <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property> <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property> <property name="hibernate.connection.url">jdbc:hsqldb:.;sql.enforce_strict_size=true</property> <property name="hibernate.connection.username">sa</property> <property name="hibernate.connection.password"></property> |
改为:
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpmtest?useUnicode=true;characterEncoding=utf-8</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">yourPasswd</property> |
e) 复制src/resources/hsqldb文件夹为mysql, 修改其中的create.db.hibernate.properties文件为:
# innodb has acid compliance, might be best to use it? hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
# could also be used maybe, see hibernate and mysql websites for more info # hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect # hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost:3306/jbpmtest?useUnicode=true&characterEncoding=utf-8 hibernate.connection.username=root hibernate.connection.password=yourPasswd
hibernate.show_sql=true hibernate.query.substitutions=true 1, false 0 hibernate.c3p0.min_size=1 hibernate.c3p0.max_size=3 |
f) 修改src/resources/下的jbpm.sar,首先修改jbpm.hibernate.properties文件为:
# innodb has acid compliance, might be best to use it? hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
# could also be used maybe, see hibernate and mysql websites for more info # hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect # hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver hibernate.connection.url=jdbc:mysql://localhost:3306/jbpmtest?useUnicode=true&characterEncoding=utf-8 hibernate.connection.username=root hibernate.connection.password=yourPasswd
hibernate.show_sql=true hibernate.query.substitutions=true 1, false 0 hibernate.c3p0.min_size=1 hibernate.c3p0.max_size=3 |
其次找到META-INF下的jboss-service.xml文件的如下行:
<depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends> |
修改DefaultDS为MySqlDS。
g) 修改build.xml文件,找到<!-- package the jbpm service archive in a .sar -->,向下找四行<fileset dir="lib/hibernate">在 <include name="ehcache-1.1.jar" />后添一行:<include name="c3p0- 0.8.5 .2.jar" />;向下找6行添加:
<fileset dir="lib/mysql"> <include name="mysql-connector-java- 3.1.7 -bin.jar" /> </fileset> |
h) 修改build.deploy.xml,将:
<target name="create.db" depends="declare.jbpm.tasks, db.clean, db.start" description="creates a hypersonic database with the jbpm tables and loads the processes in there"> <jbpmschema actions="create" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"/> <loadidentities file="${basedir}/src/resources/hsqldb/identity.db.xml" properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"/> <ant antfile="build.xml" target="build.processes" inheritall="false" /> <deploypar properties="${basedir}/src/resources/hsqldb/create.db.hibernate.properties"> <fileset dir="build" includes="*.par" /> </deploypar> <antcall target="db.stop" /> </target> |
改为:
<target name="create.db" depends="declare.jbpm.tasks" description="Create a MySQL Database with the jbpm tables"> <jbpmschema actions="create" properties="${basedir}/src/resources/mysql/create.db.hibernate.properties"/> <loadidentities file="${basedir}/src/resources/mysql/identity.db.xml" properties="${basedir}/src/resources/mysql/create.db.hibernate.properties"/> <ant antfile="build.xml" target="build.processes" inheritall="false" /> <deploypar properties="${basedir}/src/resources/mysql/create.db.hibernate.properties"> <fileset dir="build" includes="*.par" /> </deploypar> </target> |
找到<!-- copy the jbpm database -->节,将该节全部注释掉。
i) 右击build.deploy.xml,选择RUN AS ANT BUILD,如果提示错误,检查上面的配置文件是否配置正确。此时,在JBOSS_HOME/server/目录下多了一个jbpm目录。在JBOSS_HOME/bin目录下输入run.bat -c jbpm运行JBOSS。启动完成后在浏览器里面输入http://localhost:8080/jbpm即可看到你期望的界面。