2.6. Configuring a Datasource for JBoss Enterprise Application Platform 6

The default configuration uses 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.
The following procedure uses a PostgreSQL database as an example.

Procedure 2.4. Configuring a Datasource for JBoss Enterprise Platform 6

  1. Add a directory for the database to the JBoss Enterprise Application Platform 6 directory structure. The directory should be named for the database that will be used. For instance, for a PostgreSQL database create the following structure:
    jboss-eap-6.0/modules/org/postgresql/
    For a MySQL database, create the following structure:
    jboss-eap-6.0/modules/com/mysql/
  2. Download the corresponding JBDC driver for the database.
  3. Create a main directory in the directory created for the database:
    jboss-eap-6.0/modules/org/postgresql/main/
    Copy the JBDC driver into the jboss-eap-6.0/modules/org/postgresql/main/ directory.
  4. Create a module.xml file and save it to jboss-eap-6.0/modules/org/postgresql/main/ with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="org.postgresql">
    	<resources>
    		<resource-root path="postgresql-8.4-xxx.jdbc4.jar"/>
    	</resources>
    	<dependencies><module name="javax.api"/></dependencies>
    </module>
  5. Edit the profile configuration file, for instance, jboss-eap-6.0/standalone/configuration/standalone.xml configured for a PostgreSQL database called jbpmDS, and a user called sa with a password sa:
    <subsystem xmlns="urn:jboss:domain:datasources:1.1">
       <datasources>
          <datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="java:jboss/datasources/jbpmDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
             <connection-url>jdbc:postgresql:mem:test;DB_CLOSE_DELAY=-1</connection-url>
             <driver-class>org.postgresql.Driver</driver-class>
             <driver>postgresql-jdbc4</driver>
             <pool>
                <min-pool-size>2</min-pool-size>
                <max-pool-size>20</max-pool-size>
                <prefill>true</prefill>
             </pool>
             <security>
                <user-name>sa</user-name>
                <password>sa</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>
                <use-fast-fail>false</use-fast-fail>
             </validation>
          </datasource>
          <drivers>
             <driver name="postgresql-jdbc4" module="org.postgresql"/>
          </drivers>
       </datasources>
    </subsystem>
  6. Edit the jboss-eap-6.0/standalone/deployments/business-central-server.war/WEB-INF/classes/META-INF/persistence.xml file and change the hibernate dialect to PostgreSQL:
    <jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
    .
    .
    <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
  7. Edit the jboss-eap-6.0/standalone/deployments/jbpm-human-task.war/WEB-INF/classes/META-INF/persistence.xml file and change the hibernate dialect to PostgreSQL:
    <non-jta-data-source>java:jboss/datasources/jbpmDS</non-jta-data-source>
    .
    .				
    <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>