Monday 20 April 2015

Configure Oracle 11g Database with JBPM 6.2.0


JBPM 6.2.0 comes with Default "h2" database.


To Configure JBPM 6.2.0 with Oracle 11g database, you have to configure following files:

  • jbpm-installer\db\jbpm-persistence-JPA2.xml
  • jbpm-installer\standalone-*.xml
  • jbpm-installer\build.properties

The following files define the persistence settings for the jbpm-installer demo:
  • jbpm-installer/db/jbpm-persistence-JPA2.xml
  • Application server configuration
    • standalone-*.xml

Do the following:


Disable default H2 database and enable oracle 11g database in "jbpm-installer\build.properties"
# default is H2
#H2.version=1.3.168
#db.name=h2
#db.driver.jar.name=h2-${H2.version}.jar
#db.driver.download.url=http://repo1.maven.org/maven2/com/h2database/h2/${H2.version}/h2-${H2.version}.jar
#oracle
db.name=oracle
db.driver.module.prefix=oracle/jdbc
db.driver.jar.name=ojdbc7-12.1.0.2.jar
db.driver.download.url=https://code.lds.org/nexus/content/groups/main-repo/com/oracle/ojdbc7/12.1.0.2/ojdbc7-12.1.0.2.jar

Change in following file for Hibernate sql.dailect 



  • jbpm-installer\db\jbpm-persistence-JPA2.xml


This is the JPA persistence file that defines the persistence settings used by jBPM for both the process engine information, the logging/BAM information and task service.
In this file, you will have to change the name of the hibernate dialect used for your database.

The original line is:
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
In the case of an Oracle database, you need to change it to:
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />


  • jbpm-installer\standalone-*.xml


This file is the configuration for the standalone JBoss application server. When the installer installs the demo, it copies these files to the standalone/configuration directory in the jboss server directory.

We need to change the datasource configuration in standalone.xml so that the jBPM process engine can use our Oracle 11g database
The original file contains the following lines:


<datasource jndi-name="java:jboss/datasources/jbpmDS" enabled="true" use-java-context="true" pool-name="H2DS">
    <connection-url>jdbc:h2:tcp://localhost/runtime/jbpm-demo</connection-url>
    <driver>h2</driver>
    <pool></pool>
    <security>
       <user-name>sa</user-name>
       <password></password>
    </security>
</datasource>
<drivers>
    <driver name="h2" module="com.h2database.h2">
        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
</drivers>

Change the line to the following:

<datasource jta="true" jndi-name="java:jboss/datasources/jbpmDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">
    <connection-url>jdbc:oracle:thin:@xxx.xxx.xxx.xxx:XXXX:sid</connection-url>
        <driver>oracle</driver>
        <security>
            <user-name>jbpm</user-name>
            <password>jbpm</password>
        </security>
</datasource>
<drivers>
    <driver name="oracle" module="oracle.jdbc">
        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
    </driver>
</drivers>

Change same for "ExampleDS"

<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
 <connection-url>jdbc:oracle:thin:@xxx.xxx.xxx.xxx:XXXX:sid</connection-url>
        <driver>oracle</driver>
        <security>
            <user-name>jbpm</user-name>
            <password>jbpm</password>
        </security>
</datasource>

NOTES: 
  • xxx.xxx.xxx.xxx = database ip address, XXXX= database port number, sid = SID

  • Create a User called "jbmp" in database

Run "jBPM data base schema scripts (DDL scripts)" which you can find in following path:
jbpm-installer/db/ddl-scripts/oracle


  • Change the db.driver.module.prefix property in build.properties to the same “value” you used for the module name in standalone.xml. In the example above, I used “oracle.jdbc” which means that I should then use oracle/jdbc for the db.driver.module.prefix property.

Note: It's already done above.


  • Lastly, you'll have to create the db/${db.name}_module.xml file. As an example you can use db/mysql_module.xml, so just make a copy of it and:
    • Change the name of the module to match the db.driver.module.prefix property above
    • Change the name of the module resource to the name of the JDBC driver jar that was downloaded.

The top of the original file looks like this:

<module xmlns="urn:jboss:module:1.0" name="com.mysql">
   <resources>
     <resource-root path="mysql-connector-java.jar"/>
   </resources>

So we will create "oracle_module.xml" in db folder which looks like following file:

<module xmlns="urn:jboss:module:1.0" name="oracle.jdbc">
   <resources>
     <resource-root path="ojdbc7-12.1.0.2.jar"/>
   </resources> 
    <dependencies>
      <module name="javax.api"/>
      <module name="javax.transaction.api"/>
    </dependencies>
</module>

After all this changes, you have to install this changes, for that:

  • If demo is running then, stop it
ant stop.demo
  • clean old installation 
ant clean.demo
  • reinstall demo
ant install.demo
  • start demo
ant start.demo
    


2 comments:

  1. running clean command deletes the jboss folder. How can I control that? Is it a must to run clean command?

    ReplyDelete
  2. Hi Prashant,

    I have created all the tables under JBPM schema in DB2 database. also i have set the default schema as JBPM in persistance.xml ( ) .

    The business central war starts without any issue , but when i click on the process instance tab , the query is failing it is using DB2Admin.tablename and not JBPM.table name. DB2ADMIN is the user name i have confiugred for datasource.
    My DBA has created tables under JBPM schema so i am facing issues, any work for this ?
    I am using JBPM suite 6.

    ReplyDelete