Configure jBPM with MySQL

Hello Guys, Here is my next post on jBPM, the most flexible option of jBPM is that, it can be configured with major Database vendors of market like Oracle, MS SqlServer, MySql,etc. In this post i want to explain how to download the latest jBPM and configure it with MySQL

Step 1: please download “jbpm-5.4.0.Final-installer-full.zip”
Step 2: Extract it to your preferred locations of your PC.
Step 3: Setup Mysql Database.
Step 4: With MySQL installed, log in as the root user and run the following commands

mysql> CREATE SCHEMA IF NOT EXISTS jbpm5;
mysql> CREATE USER 'jbmp5'@'localhost' IDENTIFIED BY 'jbpm5';
mysql> GRANT ALL PRIVILEGES ON jbpm5.* TO 'jbpm5'@'localhost';

mysql> CREATE SCHEMA IF NOT EXISTS task;
mysql> CREATE USER 'task'@'localhost' IDENTIFIED BY 'task';
mysql> GRANT ALL PRIVILEGES ON task.* TO 'task'@'localhost;

Set up jBPM
Step 5:

ant clean.demo

Second, you will have to change the following files:

a. build.properties
b. db/jbpm-persistence-JPA2.xml
c. db/task-persistence-JPA2.xml
d. standalone.xml
e. task-service/resources/META-INF/persistence.xml
f. lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml
g. lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml

build.properties
change:

# data base related properties
db.driver.jar=${install.home}/db/driver/${db.driver.jar.name}
db.driver.module.dir=${jboss.home}/modules/${db.driver.module.prefix}/main/
# default is H2
db.name=h2
db.driver.jar.name=${db.name}.jar
db.driver.download.url=http://repo1.maven.org/maven2/com/h2database/h2/${H2.version}/h2-${H2.version}.jar
#other options are mysql
#  db.name=mysql
#  db.driver.module.prefix=com/mysql
#  db.driver.jar.name=${db.name}-connector-java.jar
#  db.driver.download.url=https://repository.jboss.org/nexus/service/local/repositories/central/content/mysql/mysql-connector-java/5.1.18/mysql-connector-java-5.1.18.jar
#postresql
#  db.name=postresql
#  db.driver.module.prefix=org/postgresql
#  db.driver.jar.name=${db.name}-jdbc.jar
#  db.driver.download.url=https://repository.jboss.org/nexus/content/repositories/thirdparty-uploads/postgresql/postgresql/9.1-902.jdbc4/postgresql-9.1-902.jdbc4.jar

To:

# data base related properties
db.driver.jar=${install.home}/db/driver/${db.driver.jar.name}
db.driver.module.dir=${jboss.home}/modules/${db.driver.module.prefix}/main/
#  default is H2
#  db.name=h2
#  db.driver.jar.name=${db.name}.jar
#  db.driver.download.url=http://repo1.maven.org/maven2/com/h2database/h2/${H2.version}/h2-${H2.version}.jar
#other options are mysql
  db.name=mysql
  db.driver.module.prefix=com/mysql
  db.driver.jar.name=${db.name}-connector-java.jar
  db.driver.download.url=https://repository.jboss.org/nexus/service/local/repositories/central/content/mysql/mysql-connector-java/5.1.18/mysql-connector-java-5.1.18.jar
#postresql
#  db.name=postgresql
#  db.driver.module.prefix=org/postgresql
#  db.driver.jar.name=${db.name}-jdbc.jar
#  db.driver.download.url=https://repository.jboss.org/nexus/content/repositories/thirdparty-uploads/postgresql/postgresql/9.1-902.jdbc4/postgresql-9.1-902.jdbc4.jar

db/jbpm-persistence-JPA2.xml

change:

<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />

To:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

standalone.xml

Change:

<datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">
  <connection-url>jdbc:h2:~/jbpm</connection-url>
  <driver>h2</driver>
  <pool>
    <min-pool-size>1</min-pool-size>
    <max-pool-size>4</max-pool-size>
    <prefill>false</prefill>
    <use-strict-min>false</use-strict-min>
    <flush-strategy>FailingConnectionOnly</flush-strategy>
  </pool>
  <security>
    <user-name>sa</user-name>
  </security>
  <validation>
    <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
    <validate-on-match>false</validate-on-match>
    <background-validation>false</background-validation>
  </validation>
</datasource>
<drivers>
  <driver name="h2" module="com.h2database.h2">
    <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
  </driver>
</drivers>

To:

<datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="H2DS" enabled="true" use-java-context="true" use-ccm="true">
  <connection-url>jdbc:mysql://localhost:3306/jbpm5</connection-url>
  <driver>mysql</driver>
  <pool>
    <min-pool-size>1</min-pool-size>
    <max-pool-size>4</max-pool-size>
    <prefill>false</prefill>
    <use-strict-min>false</use-strict-min>
    <flush-strategy>FailingConnectionOnly</flush-strategy>
  </pool>
  <security>
    <user-name>jbpm5</user-name>
    <password>jbpm5</password>
  </security>
  <validation>
    <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
    <validate-on-match>false</validate-on-match>
    <background-validation>false</background-validation>
  </validation>
</datasource>
<drivers>
  <driver name="mysql" module="com.mysql">
    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
  </driver>
</drivers>

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

db/task-persistence-JPA2.xml

Change:

<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

To:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

task-service/resources/META-INF/persistence.xml

Change:

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
<property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/runtime/task" />
<property name="hibernate.connection.username" value="sa"/>
<property name="hibernate.connection.password" value=""/>

To:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="org.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql:://localhost:3306/task" />
<property name="hibernate.connection.username" value="task"/>
<property name="hibernate.connection.password" value="task"/>

Now its time to change the persistence.xml in lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war and lib/jbpm-human-task-war-5.4.0.Final-EE6.war. to do this install 7-zip software open the war file using 7Zip and change the persistence.xml save and close it as below.

lib/jbpm-human-task-war-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml
Change:

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />

To:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

lib/jbpm-gwt-console-server-5.4.0.Final-EE6.war/WEB-INF/classes/META-INF/persistence.xml
Change:

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />

To:

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />

Install jBPM
Run:

ant install.demo 

To start the jBPM environment you can run:

ant start.demo.db

or

ant start.demo.db.noeclipse

after you execute all the steps above and run the application, open the database and you should find your database with the tables as shown below.
jbpm5_schema

Happy Coding, Happy jBPM 🙂

Advertisements

2 thoughts on “Configure jBPM with MySQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s