在做JBPM部署时,可以用jbpm-jpdl-suite-3.2.3自带的那个JBOSS进行部署,但其也只提供基本的JBPM部署,怎样把它放在普通的JBOSS下进行部署呢?也就是怎样才能把那个jbpm-console.war包放在普通的JBOSS下进行部署呢?今天花了些时间试了一下,
数据库:MySQL5
JBPM版本:3.2.3
JBOSS版本:4.2.2
1.建立数据库jbpm,执行JBPM的MySQL数据库脚本(附件中)。
2.下载jbpm-jpdl-suite-3.2.3.zip包,然后将其解压,在jbpm-jpdl-3.2.3\server\server\jbpm\deploy下找到jbpm-console.war,将其复制到jboss-4.2.2.GA\server\default\deploy
目录下,然后再在jboss-4.2.2.GA\server\default\deploy下建立一个数据源,如名字为:jboss-ds.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>JbpmDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/jbpm</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
当然应该保证jboss-4.2.2.GA\server\default\lib下拥有MySQL的JDBC驱动包.
3.设置JAAS认证:
在jboss-4.2.2.GA\server\default\conf下找到login-config.xml文件,添加:
<application-policy name = "jbpm">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag="required">
<module-option name="dsJndiName">java:/JbpmDS</module-option>
<module-option name="principalsQuery">
SELECT PASSWORD_ FROM JBPM_ID_USER WHERE NAME_=?
</module-option>
<module-option name="rolesQuery">
SELECT g.NAME_ ,'Roles'
FROM JBPM_ID_USER u,
JBPM_ID_MEMBERSHIP m,
JBPM_ID_GROUP g
WHERE g.TYPE_='security-role'
AND m.GROUP_ = g.ID_
AND m.USER_ = u.ID_
AND u.NAME_=?
</module-option>
</login-module>
</authentication>
</application-policy>
代码。
4.在jbpm数据中插入数据:
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);
经过以上步骤后,启动JBOSS,就可以通过http://localhost:8080/jbpm-console/ 输入user:admin ,password:admin进行JBPM部署了。