JbpmOnTomcat

Posted on 2008-01-10 17:43 Martin Yuan 阅读(220) 评论(0)  编辑  收藏 所属分类: JBPM

This how-to outlines the necessary steps to get jBPM 3.2 working with Tomcat and MySQL .

It has been tested with the following environment:
Tomcat 6.0.10 (see the notes at the bottom of this page if you are using an older Tomcat version such as Tomcat 5.0.28)
MySQL 5.0.15
jBPM 3.2.GA and also with jBPM 3.2.1 (just some minor changes highlighted in the text below!)

1. Create schema and tables in MySQL



1.1 In this example a schema
'jbpm32' with a user 'jbossjbpm' is used.

1.2 Generate all jBPM tables using the script from the downloaded jBPM 3.2 suite, which has to be modified a bit to suite the MySQL syntax. Attached to this page is a script (jbpm.jpdl.mysql.sql) with these modifications already done - just for your convenience! If you want your users/roles information (the identity components) also from the MySQL db, use the second sql script attached here (mysql.identity.script.sql for jBPM 3.2.GA and mysql.identity.script.jbpm321.sql for jBPM 3.2.1) to set up the necessary tables and fill them with the demo values.

2. Prepare your jBPM archive



2.1 In jbpm-jpdl-3.2.GA/deploy (or jbpm-jpdl-3.2.1/deploy) run
ant customize.console.for.tomcat


2.2 This builds a jbpm-console.war in jbpm-jpdl-3.2.GA/deploy/customized (almost) ready for deployment in TC

2.3 Change the jbpm-console.war/WEB-INF/classes/hibernate.cfg.xml to reflect the following changes:

 1 <hibernate-configuration>
 2   <session-factory>
 3
 4     <!-- hibernate dialect -->
 5     <property name = " hibernate.dialect " >org.hibernate.dialect.MySQLInnoDBDialect</property>
 6
 7     <!-- JDBC connection properties (begin) -->
 8     <property name = " hibernate.connection.driver_class " >com.mysql.jdbc.Driver</property>
 9     <property name = " hibernate.connection.url " >jdbc:mysql://localhost: 3306 /jbpm32</property>
10     <property name = " hibernate.connection.username " >jbossjbpm</property>
11     <property name = " hibernate.connection.password " >jbossjbpm</property>
12      <!-- JDBC connection properties (end) -->
13     
14     <property name = " hibernate.cache.provider_class " >org.hibernate.cache.HashtableCacheProvider</property>
15     
16     <!-- DataSource properties (begin)  ==
17     <property name = " hibernate.connection.datasource " >java:/JbpmDS</property>
18      ==  DataSource properties (end) -->
19     <property name = " hibernate.transaction.factory_class " >org.hibernate.transaction.JDBCTransactionFactory</property>
20
21


(Make sure to use the hibernate.connection.driver/url attributes to connect to the db and not the hibernate.connection.datasource property. Also set hibernate.transaction.factory_class to JDBCTransactionFactory? instead of the JTATransactionFactory? or CMTTransactionFactory? which are already in this file.)

2.4 Copy jboss-j2ee.jar (or maybe as well any jar that contains the default javax.transaction package) to jbpm-console.war/WEB-INF/lib. (Note: jboss-j2ee.jar can be found in a standard JBoss AS distribution eg. jboss-4.0.5.GA/client)

2.4.1 FOR jBPM 3.2.1 ONLY: Copy commons-collections.jar to jbpm-console.war/WEB-INF/lib. (Note: commons-collections.jar can be found in a standard JBoss AS distribution eg. jboss-4.0.5.GA/server/default/lib)

2.5 Copy the jar containing the mysql jdbc driver to /$CATALINA_HOME/lib

2.6 Copy the adapted jbpm-console.war to /$CATALINA_HOME/webapps

You can now give it a try and start Tomcat. You should be able to start the jbpm web application, but for now you cannot successfully log in.

Next thing to do would be to properly configure your security realm. You could either go for the standard file based MemoryRealm? and just add the jBPM specific users and roles to /$CATALINA_HOME/conf/tomcat-users.xml, OR...

3. Setup a JDBC Realm in Tomcat



3.1 Create a file jbpm-console.xml in /$CATALINA_HOME/conf/Catalina/localhost similar to

 1 <Context>
 2 <Realm  className = " org.apache.catalina.realm.JDBCRealm "  
 3     driverName = " com.mysql.jdbc.Driver "
 4     connectionURL = " jdbc:mysql://localhost:3306/jbpm32 "
 5     connectionName = " jbossjbpm "  
 6     connectionPassword = " jbossjbpm "
 7     userTable = " JBPM_ID_USER u, JBPM_ID_MEMBERSHIP m, JBPM_ID_GROUP g "  
 8     userNameCol = " g.TYPE_ = 'security-role' AND m.GROUP_ = g.ID_ AND m.USER_ = u.ID_ AND u.NAME_ "  
 9     userCredCol = " DISTINCT u.PASSWORD_ "
10     userRoleTable = " JBPM_ID_USER u, JBPM_ID_MEMBERSHIP m, JBPM_ID_GROUP g "  
11     roleNameCol = " g.NAME_ "  />
12 </Context>
13


Now you should be able to run jBPM default web app in Tomcat and login with the username/password (eg. ernie/ernie for jBPM 3.2.GA or manager/manager for jBPM 3.2.1) from the db.


(Note: This how-to first found its way in this post, so you might find some more discussion about this there.)


(Notes for users of older Tomcat versions, such as Tomcat 5.0.28: Tomcat 5.0.28 doesn't include the el*.jars by default as the TC 6.0 series does, you will have to repackage el-api.jar and el-ri.jar back into jbpm-console.war/WEB-INF/lib (these files get deleted by the ant call described in step 2.1 above and can be found in the original web app jbpm-jpdl-3.2.1/deploy/jbpm-console.war/WEB-INF/lib). In addition, the included xml parses make problems as well, so you will also have to replace/delete the content in common/endorsed.)


Attachments:



I just want to live while i'm alive .


只有注册用户登录后才能发表评论。


网站导航: