Friday 19 August 2011

Set up JBPM – Oracle - Tomcat 6

1. Add transaction and Resource information after 'WatchedResource' line in TOMCAT_HOME/conf/context.xml as shown below. This step is required to create a datasource in tomcat

<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Transaction factory ="bitronix.tm.BitronixUserTransactionObjectFactory" />

<Resource name="jdbc/testDS1" auth="Container" type="javax.sql.DataSource" maxActive="15" maxIdle="2" maxWait="10000" logAbandoned="true"username="username" password="password" driverClassName=" oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@yourdatabaseurl:port:db"/>


2. Create 'resource.properties' in TOMCAT_HOME/conf and add following as shown below.
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=oracle.jdbc.OracleDriver

3. Copy oracle ojdbc14.jar into the ‘tomcat/lib’ and ‘jbpm-installer/runtime’ folder for oracle driver.

4. Modify hibernate.cfg.xml in TOMCAT_HOME\webapps\gwt-console-server\WEB-INF\classes\META-INF to include Oracle connection details and comment the h2 details.
Note: Its better to change into the WAR (gwt-console-server.war) itself so can be deployed on different instances.

Replace the session-factory tag from below
<session-factory>
<!-- h2 Database connection settings -->
<!--property name="connection.url">jdbc:h2:file:/NotBackedUp /data/mydb</property-->
<!--
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:tcp://localhost/~/test</ property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
-->
<!-- Oracle Database connection settings -->
<property name="connection.driver_class"& gt;oracle.jdbc.OracleDriver</property>
<property name="connection.url">
jdbc:oracle:thin:@yourdatabaseurl:port:db</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</ property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread& lt;/property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class"& gt; 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>

5. Make sure the jbpm-human-task-5.0-SNAPSHOT.jar is in TOMCAT_HOME/webapps/gwt-console-server/WEB-INF/lib (5.1 full installer zip contains this jar in the gwt-console-server web-inf lib) OR if not present then download and copy jbpm-human-task-5.0-SNAPSHOT.jar to TOMCAT_HOME/webapps/gwt-console-server/WEB-INF/lib

6. Make sure the jbpm-bam-5.0-SNAPSHOT.jar is in TOMCAT_HOME/webapps/gwt-console-server/WEB-INF/lib (5.1 full installer zip contains this jar in the gwt-console-server web-inf lib) OR if not present then download and copy copy jbpm-bam-5.0-SNAPSHOT.jar to TOMCAT_HOME/webapps/gwt-console-server/WEB-INF/lib

7. Add or Replace oracle connection details in persistence.xml of TOMCAT_HOME\webapps\gwt-console-server\WEB-INF\classes\META-INF.

<persistence-unit name="org.jbpm.persistence.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jdbc/testDS1</jta-data-source>
<mapping-file>META-INF/JBPMorm.xml</mapping-file>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.jbpm.process.audit.ProcessInstanceLog</class>
<class>org.jbpm.process.audit.NodeInstanceLog</class>
<class>org.jbpm.process.audit.VariableInstanceLog</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>


8. Modify the jbpm-bam-5.1.0.Final.jar/hibernate.cfg.xml of to add the oracle connection properties. Replace the session-factory with the following xml.

<session-factory>
<!-- h2 Database connection settings -->
<!--property name="connection.url">jdbc:h2:file:/NotBackedUp/data/mydb</property-->
<!--
<property name="connection.driver_class">org.h2.Driver</property>
<property name="connection.url">jdbc:h2:tcp://localhost/~/test</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
-->
<!-- Oracle Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">
jdbc:oracle:thin:@yourdatabaseurl:port:db</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</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>


9. Make sure all the above modified jars (jbpm-bam-5.1.0.Final.jar, jbpm-human-task-5.1.0.Final.jar) are also present/copied to the jbpm-installer/runtime folder before running ‘ant start.human.task’ from jbpm-installer. On running the task, all the tables will be created in oracle schema.

5 comments:

  1. Hi,

    Nice post.
    are the instructions same for the 5.2 version?

    Thanks and regrads,
    Amogh

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Great post! Do you have instructions for performing the same installation with JBPM 6.2 and oracle Database?

    ReplyDelete
  4. titanium cross necklace - Tita Games - Tita Games - Tita
    Tita Games. nano titanium Tita Games. Tita Games. titanium dog teeth implants Tita columbia titanium jacket Games. Tita Games. titanium bike frame Tita Games. Tita Games. Tita Games. Tita Games. Tita Games. Tita Games. Tita Games. Tita Games. Tita Games. westcott titanium scissors Tita Games. Tita Games. Tita Games. Tita Games. Tita Games.

    ReplyDelete