2.5. Configuring a Datasource for JBoss Enterprise Web Server

The default configurations use embedded databases that are not suitable or supported for production environments. Before deploying into a production environment, this configuration must be changed to a supported database. JBoss Enterprise Web Server users must configure jbpm-human-task.war and business-central-server.war.
The following example uses a MySQL database.

Procedure 2.3. Configuring a datasource for JBoss Enterprise Web Server

  1. Copy the MySQL driver to tomcat6/lib/
  2. Configure the datasource resources in tomcat6/conf/context.xml:
    <Resource name="jdbc/jbpmDS" auth="Container" type="javax.sql.DataSource" factory="bitronix.tm.resource.ResourceObjectFactory" uniqueName="jdbc/jbpmDS"/>
    
    <Resource name="jdbc/jbpmTasksDS" auth="Container" type="javax.sql.DataSource" factory="bitronix.tm.resource.ResourceObjectFactory" uniqueName="jdbc/jbpmTasksDS"/>
    
  3. Edit the tomcat6/webapps/business-central-server.war/WEB-INF/Classes/META-INF/persistence.xml file to include the unique name from context.xml:
    		<jta-data-source>java:/comp/env/jdbc/jbpmDS</jta-data-source>  
    ...
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
    <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
    
  4. Edit the tomcat6/webapps/jbpm-human-task.war/WEB-INF/classes/META-INF/persistence.xml file to include the unique name from context.xml:
    <jta-data-source>java:/comp/env/jdbc/jbpmTasksDS</jta-data-source>  
    ...
    <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> 
    <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
    
  5. JBoss Enterprise Web Server does not include a transaction manager. The following example shows the configuration for Bitronix, and it is provided for evaluation purposes only. Bitronix can be downloaded from http://docs.codehaus.org/display/BTM/Home.
    	#file resources.properties
    	resource.ds1.className=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
    	resource.ds1.uniqueName=jdbc/jbpmDS
    	resource.ds1.minPoolSize=0
    	resource.ds1.maxPoolSize=10
    	resource.ds1.driverProperties.user=guest
    	resource.ds1.driverProperties.password=guest
    	resource.ds1.driverProperties.URL=jdbc:mysql://localhost:3306/jbpmprocess
    	resource.ds1.allowLocalTransactions=true
    
    	resource.ds2.className=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
    	resource.ds2.uniqueName=jdbc/jbpmTasksDS
    	resource.ds2.minPoolSize=0
    	resource.ds2.maxPoolSize=10
    	resource.ds2.driverProperties.user=guest
    	resource.ds2.driverProperties.password=guest
    	resource.ds2.driverProperties.URL=jdbc:mysql://localhost:3306/jbpmtasks
    	resource.ds2.allowLocalTransactions=true
    
  6. To configure the Bitronix transaction manager, create a tomcat6/conf/btm-config.properties file:
    bitronix.tm.serverId=tomcat-btm-node0
    bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog
    bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog
    bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties
    Add the following line to tomcat6/conf/context.xml:
    <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory"/>
    Add the following line to tomcat6/conf/server.xml
    <Listener className="bitronix.tm.integration.tomcat55.BTMLifecycleListener"/>
    Create a configuration properties file. On unix based systems the file should be tomcat6/setenv.sh, and on Windows systems the file should be tomcat6/setenv.bat.
    CATALINA_OPTS="-Dbtm.root=$CATALINA_HOME -Dbitronix.tm.configuration=$CATALINA_HOME/conf/btm-config.properties"