Friday, February 13, 2009

Installing JBoss+jBPM+MySQL

Well, the information is a little bit spread on the Internet, so I'd like to post some tips what I found to resolve some issues:
  • Assuming a host machine Linux Ubuntu 8.10 with a Java SDK properly installed (set $JAVA_HOME and $PATH)
  • Until today JBoss 5.0 is incompatible with jBPM 3.3.1, so you have to use JBoss 4.2.3
    See here: https://jira.jboss.org/jira/browse/JBPM-1913
    and here: http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4195183#4195183
  • You could install JBoss 4.2.x (Application Server) using apt-get/aptitude or downloading it from jboss.org)
  • Once JBoss 4.2.3 has been installed in your box, check that's running fine. Then, install the MySQL server 5.0 (you could use apt-get or aptitude)
  • Next, create a database 'jbossdb' with a granted user 'jboss' to conect it with a password.
  • Download the database connector J from the MySQL site
  • Copy the .jar file to {JBOSS_HOME}/server/default/lib
  • Afterwards, you have to change the configuration files in the JBoss server as follows:
(Note that in this case {JBOSS_HOME} = /usr/local/jboss)


# cd /usr/local/jboss/server/default/conf


Edit login-config.xml changing the corresponding hsqldb entry by the mysql values:





jbossdb
jboss
password
jboss.jca:service=LocalTxCM,name=DefaultDS





Then, edit standardjbosscmp-jdbc.xml


java:/DefaultDS
mySQL
...



Next, change the directory:

#cd /usr/local/jboss/server/default/deploy


Create the file mysql-ds.xml with the following entries:



MySQLDB
jdbc:mysql://localhost:3306/jbossdb
com.mysql.jdbc.Driver
jboss
password

MySqlDbRealm

mySQL


10
20

5


com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter


com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker





After that, remove the file hsqldb-ds.xml. Next restart your Jboss server.

Until here you have your Jboss server configured with MySQL server. Now you can install jBPM.
  • First of all, download jBPM 3.3.1 from jboss.org
  • Next, execute the jar installer indicating the Jboss version, its directory and the location where you're gonna install jBPM. Also you have to indicate that you're using MySQL.
  • Moreover, you have to create a database 'jbpmdb' with a granted user 'jbpm' to conect it with a password



#java -jar jbpm-installer-3.3.1.GA.jar

(Note that in this case {JBPM_HOME} = /usr/local/jbpm)

Once the jBPM has been installed, you have to follow the next steps:

#cd /usr/local/jboss/server/default/deploy/jbpm


Edit the file jbpm-mysql-ds.xml as follows:




JbpmDS

com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
jdbc:mysql://localhost:3306/jbpmdb
jbpm
password


TRANSACTION_READ_COMMITTED







com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter


com.mysql.jdbc.integration.jboss.MysqlValidConnectionChecker




mySQL






Next, change to this directory:

# cd /usr/local/jboss/server/default/deploy/jbpm/jbpm-service.sar


Edit the file hibernate.cfg.xml:


org.hibernate.dialect.MySQLInnoDBDialect


...


With these steps you're ready to re-start your JBoss server and check the jBPM console at http://localhost:8080/jbpm-console (replace localhost by your real server or something else).

Well done until here, however, when you use jBPM with another Data Base instead the default one (hsqldb), you have to create the tables used by jBPM and insert some values too. That's because you cannot enter the jbpm-console with the predefined users. So, you just have to follow these steps:

#cd /usr/local/jbpm/database


Next, login in the jbpmdb database and execute the script:

mysql# source jbpm.jpdl.mysql.sql;
...
mysql# quit;


Now, you have to insert the proper values as follows:

insert into JBPM_ID_USER (ID_, CLASS_, NAME_, EMAIL_, PASSWORD_)
values ('1', 'U', 'user', 'sample.user@sample.domain', 'user');
insert into JBPM_ID_USER (ID_,CLASS_, NAME_, EMAIL_, PASSWORD_)
values ('2', 'U', 'manager', 'sample.manager@sample.domain', 'manager');
insert into JBPM_ID_USER (ID_,CLASS_, NAME_, EMAIL_, PASSWORD_)
values ('3', 'U', 'shipper', 'sample.shipper@sample.domain', 'shipper');
insert into JBPM_ID_USER (ID_,CLASS_, NAME_, EMAIL_, PASSWORD_)
values ('4', 'U', 'admin', 'sample.admin@sample.domain', 'admin');


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','user@sample.domain','user');
INSERT INTO JBPM_ID_USER VALUES(2,'U','manager','manager@sample.domain','manager');
INSERT INTO JBPM_ID_USER VALUES(3,'U','admin','admin@sample.domain','admin');
INSERT INTO JBPM_ID_USER VALUES(4,'U','shipper','shipper@sample.domain','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);


Finally, you can connect to the jBPM console at http://localhost:8080/jbpm-console (replace localhost by your real server or something else).
Afterwards, you can install Eclipse and the JPDL designer for modeling you processes. For that, download the JBoss Tools and install them into Eclipse.
To start modeling, just visit these links:

http://www.jboss.org/community/docs/DOC-11184

http://www.mastertheboss.com/en/jbpm/51-jbpm-tutorial-part-1.html

Any comment is very welcome.

---
Ricardo Seguel P.

5 comments:

Anonymous said...

Thanks,

This helped a lot, though I was using Jboss AS 5 which needed some modifications.

Edward,

eodonnell at u c s d dot edu

bharathi s said...

Hi,

Its nice article one. I am using jboss esb 4.5 standalone server for running my esb and jbpm. I followed your steps.But i am not able to run successfully. Its not connecting to MySql DB. I am using windows OS.

Regards,
Bharathi S.

bharathi s said...
This comment has been removed by the author.
bharathi s said...
This comment has been removed by the author.
for IT the said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai