jbpm移植到tomcat6+mysql上

jbpm一直都是发布在jboss上,由于我们的开发工具集成的tomcat比较好,所以打算经他移植到tomcat上可以进行时时的运行跟踪和修改,期间碰到了一些问题,下面列一下步骤

1、首先下载jbpm-jpdl-suite-3.2.3.zip,从他的官方网站可以下载,然后解压

2、开发eclipse,创建普通java工程,并使用tomcat plugin发布服务

3、创建数据库jbpm,然后执行叫表语句,db/jbpm.jpdl.mysql.sql

4、拷贝src下的类靠工程的src下

5、修改配置src/hibernate.cfg.xml,添加

 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
 <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
 <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm</property>
 <property name="hibernate.connection.username">root</property>
 <property name="hibernate.connection.password">admin</property>

注意将

<!-- property name="hibernate.connection.datasource">java:comp/env/jdbc/JbpmDataSource</property-->屏蔽了,否则在运行hibernate会报错

6、添加用户

有web.xml中可以看到jbpm采用的是系统的用户,所以可以修改配置,当然二种方式

第一种就是直接修改tomcat的用户

<tomcat-users>

  <role rolename="user"/>

  <role rolename="administrator"/>

  <role rolename="manager"/>

  <role rolename="sales"/>

  <role rolename="hr"/>

  <role rolename="admin"/>

  <role rolename="participant"/>

  <user username="user" password="user" roles="user,sales"/>

  <user username="shipper" password="shipper" roles="user,hr"/>

  <user username="manager" password="manager" roles="admin,hr,manager,user,sales"/>

  <user username="tadmin" password="" roles="admin,manager"/>
  <user username="admin" password="admin" roles="admin,user,hr"/>
</tomcat-users>

第二种方式就是依据原理,在我们的web应用中添加一个Realm进行数据的管理,从数据库中进行用户和权限的验证

 <Realm  className="org.apache.catalina.realm.JDBCRealm"
    driverName="com.mysql.jdbc.Driver"
    connectionURL="jdbc:mysql://localhost:3306/jbpm"
    connectionName="root"
    connectionPassword="admin"
    userTable=" JBPM_ID_USER u, JBPM_ID_MEMBERSHIP m, JBPM_ID_GROUP g "
    userNameCol=" g.TYPE_ = 'security-role' AND m.GROUP_ = g.ID_ AND m.USER_ = u.ID_ AND u.NAME_ "
    userCredCol=" DISTINCT u.PASSWORD_ "
    userRoleTable=" JBPM_ID_USER u, JBPM_ID_MEMBERSHIP m, JBPM_ID_GROUP g "
    roleNameCol=" g.NAME_ " />

当然默认的数据库中的表中都没有数据,需要执行添加数据语句

INSERT INTO JBPM_ID_GROUP VALUES(1,'G','sales','organisation',NULL);

      INSERT INTO JBPM_ID_GROUP VALUES(2,'G','admin','security-role',NULL);

      INSERT INTO JBPM_ID_GROUP VALUES(3,'G','user','security-role',NULL);

      INSERT INTO JBPM_ID_GROUP VALUES(4,'G','hr','organisation',NULL);

      INSERT INTO JBPM_ID_GROUP VALUES(5,'G','manager','security-role',NULL);

      INSERT INTO JBPM_ID_USER VALUES(1,'U','user','[email protected]','user');

      INSERT INTO JBPM_ID_USER VALUES(2,'U','manager','[email protected]','manager');

      INSERT INTO JBPM_ID_USER VALUES(3,'U','admin','[email protected]','admin');

      INSERT INTO JBPM_ID_USER VALUES(4,'U','shipper','[email protected]','shipper');

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(1,'M',NULL,NULL,2,4);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(2,'M',NULL,NULL,3,4);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(3,'M',NULL,NULL,4,4);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(4,'M',NULL,NULL,4,3);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(5,'M',NULL,NULL,1,3);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(6,'M',NULL,NULL,2,3);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(7,'M',NULL,NULL,3,3);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(8,'M',NULL,NULL,3,2);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(9,'M',NULL,NULL,2,2);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(10,'M',NULL,NULL,2,5);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(11,'M',NULL,'boss',2,1);

      INSERT INTO JBPM_ID_MEMBERSHIP VALUES(12,'M',NULL,NULL,1,1);

这样启动服务就可以了

注意:一定要把mysql的驱动放到tomcat/lib目录一下,因为context应用还没有启动,所以无法使用应用中的jar文件,否则会java.sql.SQLException

你可能感兴趣的:(tomcat,mysql,Hibernate,jdbc,jbpm)