The following details how to configure JBPM 5.2 running under Tomcat 7 to run the Demo application using MySQL backend vs. the default H2.

It is assumed that:

JBPM 5.2 is running under Tomcat 7 / H2 Demo running.
(See JBPM 5.2 / Tomcat 7 / H2 / Demo)

A MySQL instance has been installed and configured on the default port.

NB: Tomcat should be stopped prior to installation.

I have specified MySQL connection parameters to use the ‘root’ user id below – this should be changed to a user of your choice with appropriate rights within the MySQL instance. Root is used below to mirror the sa pattern from the demo example – that is my disclaimer for the obvious security hole here.

If using this user – the mysql root password should be updated in the credential configurations below.

1: Download required software:

MySQL JDBC Driver (Select latest version)

2: Install JDBC Driver

Copy downloaded mysql-connector-java-xxx-bin.jar to:

${CATALINA_HOME}/lib

jbpm-installer/db/driver

NB: The second step is required for the demo human-task-service only.

3: Update Tomcat Configuration

a) Update Bitronix configuration.

i) Modify file: ${CATALINA_HOME}/conf/resources.properties to contain following:

resource.ds1.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds1.uniqueName=jdbc/testDS1
resource.ds1.minPoolSize=0
resource.ds1.maxPoolSize=5
resource.ds1.driverProperties.driverClassName=com.mysql.jdbc.Driver
resource.ds1.driverProperties.user=root
resource.ds1.driverProperties.password=
resource.ds1.driverProperties.url=jdbc:mysql://localhost/test
resource.ds1.allowLocalTransactions=true

ii) Update ${CATALINA_HOME}/conf/context.xml

Add following resource declaration – replacing previous H2 entry:

<Resource name="jdbc/testDS1" auth="Container" type="javax.sql.DataSource" maxActive="15" maxIdle="2" maxWait="10000" logAbandoned="true" username="root"password="" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/test"/>

iii) If exists, delete folder: ${CATALINA_HOME}/work

4: Update hibernate configuration for the web console interface

a) Update jpbm-console

i) Update file:

${CATALINA_HOME}/webapps/jbpm-console/WEB-INF/classes/hibernate.cfg.xml

Set configuration to:

<hibernate-configuration>
<session-factory>
<!– Database connection settings –>
<property name=”connection.driver_class”>com.mysql.jdbc.Driver</property>
<property name=”connection.url”>jdbc:mysql://localhost/test</property>
<property name=”connection.username”>root</property>
<property name=”connection.password”></property>
<!– JDBC connection pool (use the built-in) –>
<property name=”connection.pool_size”>1</property>
<!– SQL dialect –>
<property name=”dialect”>org.hibernate.dialect.MySQLDialect</property>
<!– Enable Hibernate’s automatic session context management –>
<property name=”current_session_context_class”>thread</property>
<!– Disable the second-level cache –>
<property name=”cache.provider_class”>org.hibernate.cache.NoCacheProvider</property>
<!– Echo all executed SQL to stdout –>
<property name=”show_sql”>false</property>
<!– Drop and re-create the database schema on startup –>
<property name=”hbm2ddl.auto”>create</property>
<mapping resource=”AuditLog.hbm.xml”/>
</session-factory>
</hibernate-configuration>

b) Update gwt-console-server

i) Update file:

${CATALINA_HOME}/webapps/gwt-console-server/WEB-INF/classes/hibernate.cfg.xml

Set configuration to:

<hibernate-configuration>
<session-factory>
<!– Database connection settings –>
<property name=”connection.driver_class”>com.mysql.jdbc.Driver</property>
<property name=”connection.url”>jdbc:mysql://localhost/test</property>
<property name=”connection.username”>root</property>
<property name=”connection.password”></property>
<!– JDBC connection pool (use the built-in) –>
<property name=”connection.pool_size”>1</property>
<!– SQL dialect –>
<property name=”dialect”>org.hibernate.dialect.MySQLDialect</property>
<!– Enable Hibernate’s automatic session context management –>
<property name=”current_session_context_class”>thread</property>
<!– Disable the second-level cache –>
<property name=”cache.provider_class”>org.hibernate.cache.NoCacheProvider</property>
<!– Echo all executed SQL to stdout –>
<property name=”show_sql”>false</property>
<!– Drop and re-create the database schema on startup –>
<property name=”hbm2ddl.auto”>create</property>
<mapping resource=”AuditLog.hbm.xml”/>
</session-factory>
</hibernate-configuration>

ii) Update file:

${CATALINA_HOME}/webapps/gwt-console-server/WEB-INF/classes/META-INF/persistence.xml

Set content to:

<persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<class>org.drools.persistence.info.SessionInfo</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/test"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.connection.autocommit" value="true" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>

5: Update configuration of demo ‘human-task-service’

NB: The human-task-service is responsible for creating the ‘test’ demo database – this and following step represents a partial test of the MySQL connectivity and above configurations.

a) Update persistence configuration file:
jbpm-installer/task-service/target/META-INF/persistence.xml

Set ‘properties’ contents to:

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/test" />
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="false" />
</properties>

6: First test of the new configuration: Start the evaluation human task server.

Change to jpbm-installer folder and execute: ant start.human.task

NB:You will receive errors relating to JDBC connection if there is a problem with either the persistence settings configured in Step 5, or your MySQL setup.

If your local persistence required tweaking be sure to cross check the console persistence file settings updated in Step 4/b/ii above.If the human task service has started successfully it is safe to proceed.

7:  Test console

a) Start Tomcat

b) Navigate to:

http://localhost:8080/jpbm-console


Trouble Shooting

If errors are reported in the console which appear to be connected with database connectivity, verify that the test database has been created within MySQL, and check carefully the hibernate settings mentioned above.


Additional Links / Resources

Hibernate Dialect Cross Reference

Advertisements