Hello
my current situation is the following : i need to port an application developed for websphere 5 to
tomcat 6. The original developer (who has leaved my firm) had used jta for handling transactions. I'm not so experienced with
java and particularly with enterprise libraries (and neither my ex colleague i believe seeing the code) , so i need a couple of clearifications and some help on chosing the better approach to make this porting . The application is based on an Oracle database, in my (poor) knowledge of the matter , jta can be used both for distributed (through oracle xaconnection ) and common (via java.sql.connection ) transaction . I'm rather sure this application uses only java.sql.connection, but the code is a mess with multiple classes to access db, code spreaded on
jsp pages and more. So my first approach has been : don't touch the code and add jta support to tomcat. I've made two attempts the first with atomikos the second (and actual ) with bitronix but i'm not able to make work any of the two.
My questions are:
1. where can i find a short tutorial which explains fundamentals of the jta and its use with not distributed transactions (and UserTransaction)
2. the BTM says :
You have to put your datasources configurations in Tomcat's conf/resources.properties file. Here's an example of using BTM with a DataSource that implements javax.sql.XADataSource:
resource.ds1.className=org.apache.derby.jdbc.EmbeddedXADataSource
resource.ds1.uniqueName=jdbc/mydatasource
resource.ds1.minPoolSize=0
resource.ds1.maxPoolSize=5
resource.ds1.driverProperties.databaseName=../work/db1
resource.ds1.driverProperties.createDatabase=create
This will create a bitronix.tm.resource.jdbc.PoolingDataSource that implements javax.sql.DataSource and interacts with the javax.sql.XADataSource provided in this instance by Derby.
If your database vendor does not provide an XADataSource, you can use BTM's bitronix.tm.resource.jdbc.lrc.LrcXADataSource as the XADataSource to allow your database connections to be controlled by the transaction manager:
resource.ds2.className=bitronix.tm.resource.jdbc.lrc.LrcXADataSource
resource.ds2.uniqueName=jdbc/exampleNonXADS
resource.ds2.minPoolSize=0
resource.ds2.maxPoolSize=5
resource.ds2.driverProperties.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
resource.ds2.driverProperties.url=jdbc:derby:../work/db2;create=true
as stated above i don't need distributed transaction , how should configure the above for Oracle 10 and what
jdbc drivers should i use (ojdbc14.jar ? )
3. For Bitronix i've followed the tutorial at
http://docs.codehaus.org/display/BTM/Tomcat2x , and i'm been able to integrate it in Tomcat, but when the server starts (and when i try to resolve the datasource to javax.sql.DataSource in the login page ) the btm rise the following exception :
11-mar-2011 10.22.03 org.apache.naming.NamingContext lookup
AVVERTENZA: Unexpected exception resolving reference
java.lang.ClassCastException: java.lang.String cannot be cast to bitronix.tm.internal.XAResourceHolderState
at bitronix.tm.utils.Decoder.collectResourcesNames(Decoder.java:141)
at bitronix.tm.resource.ResourceObjectFactory.getObjectInstance(ResourceObjectFactory.java:57)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:140)
at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
...
11-mar-2011 10.22.03 org.apache.catalina.core.NamingContextListener addResource
AVVERTENZA: Failed to register in JMX: javax.naming.NamingException: java.lang.String cannot be cast to bitronix.tm.internal.XAResourceHolderState
can anyone give me hint about this exception please?
4. Which one is better for my situation bitronix or atomikos ? i need to keep external libraries inside the war (system administrators prefers do to keep the server clean) and configuration files outside the war
tahnk you in advance for any Help
Stefano
Some news : i've changed the resource.propeties to
resource.ds.className=oracle.jdbc.xa.client.OracleXADataSource
resource.ds.uniqueName=jdbc/NraDba
resource.ds.minPoolSize=0
resource.ds.maxPoolSize=5
resource.ds.allowLocalTransactions=true
resource.ds.testQuery=SELECT 1 FROM DUAL
resource.ds.driverProperties.user=usr
resource.ds.driverProperties.password=pwd
resource.ds.driverProperties.url=mydburl
and i got a new error at server startup :
11-mar-2011 11.57.14 org.apache.catalina.core.NamingContextListener addResource
AVVERTENZA: Failed to register in JMX: javax.naming.NamingException: no resource registered with uniqueName 'jdbc/NraDbA', available resources: []
i'm using eclipse as develpment tool