With the coming release of Apache ODE 1.3.6 and there on, one would need to integrate a transaction manager in Tomcat in order to use an external database configuration for ODE.
Here I will list down the steps to integrate one of the open source transaction managers called Bitronix in tomcat and the associated changes in ODE web application.
Step 1: Download latest bitronix archive from here.
Step 2: Copy these jars available in the bitronix archive to Tomcat\lib
- btm-2.1.4.jar
- btm-tomcat55-lifecycle-2.1.4.jar
- geronimo-jta_1.1_spec-1.1.1.jar
- slf4j-api-1.6.4.jar
- slf4j-jdk14-1.6.4.jar
Step 3: Follow Step 2 as instructed in the original guide of bitronix.
Step 4: Configure data sources
Create a file name named resources.properties under <tomcat>/conf/ directory with the below contents:
This config is for MYSQL database
resource.ds2.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds2.uniqueName=jdbc/ode
resource.ds2.minPoolSize=10
resource.ds2.maxPoolSize=50
resource.ds2.driverProperties.driverClassName=com.mysql.jdbc.Driver
resource.ds2.driverProperties.url=jdbc:mysql://localhost:3306/ode
resource.ds2.driverProperties.user=root
resource.ds2.driverProperties.password=mysql
resource.ds2.allowLocalTransactions=true
resource.ds2.shareTransactionConnections=true
Step 5: Associate the datasource created in the previous step for ODE
Create a file named ode.xml under <tomcat>/conf/Catalina/localhost/ directory with the below given contents:
<Context reloadable="true" crossContext="true">
<Resource
name="jdbc/ode"
auth="Container" type="javax.sql.DataSource"
factory="bitronix.tm.resource.ResourceObjectFactory"
uniqueName="jdbc/ode" />
</Context>
Step 6: Change the web.xml of ODE
Add these lines in the web.xml,
<resource-ref>
<res-ref-name>jdbc/ode</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Step 7: Remove duplicate jars
Remove geronimo-jta_1.1_spec-1.1.jar files from ode web application lib directory
Step 8: Edit ode-axis2.properties
ode-axis2.tx.factory.class=org.apache.ode.axis2.util.TomcatFactory
ode-axis2.db.mode=EXTERNAL
ode-axis2.db.ext.dataSource=java:comp/env/jdbc/ode
Thanks for this article. It was very helpful to me.
ReplyDeleteJurij
I tried to automate this and created an Apache Buildr project that creates a pre-configured bundle with ODE in Tomcat with BTM as transaction manager. See https://github.com/vanto/apache-ode-tomcat-bundle for details.
ReplyDeleteCan I use SQLServer instead of mysql?
ReplyDeleteThank you :)
Yes
ReplyDeleteHi Sathwik,
ReplyDeleteThe link to original guide of bitronix that you mentioned in Step 3 is broken as codehaus has terminated all its servces. Can you please update the same in the blog?
Regards,
Vinay
Kindly follow the automated script written by Tammo,
ReplyDeletehttps://github.com/vanto/apache-ode-tomcat-bundle
Thanks Sathwik, for the directions.
ReplyDeleteNice dear. visit these guys
ReplyDelete