Getting the Oracle XA datasource in place

Last time, we seemed to see a successful rollback of one resource (the JMS message receive).  Today we want to try to get the JDBC datasource to participate in the transaction, to set up for demonstrating a rollback during a full two-phase commit.

I had an Oracle datasource configuration file sitting around waiting for when I was ready to test the Hibernate portion of my XA transaction, but yesterday I took a look at it and it looks like a non-XA datasource.  For one thing, the bulk of the content is within a  <local-tx-datasource> element.  For another, there is this comment near the top:

<!--| This datasource connects to oracle.  It is a LOCAL TRANSACTION data source (as opposed to
| an XA transaction datasource

I’ll need an XA datasource, though, not a local one…

An example to work from

I found Section 8.3.2. Installing the JDBC Driver and Deploying the DataSource in JBoss’s Getting Started with JBoss 4.0 guide, which has an example Oracle XA datasource.  I started with that example and made the following changes:

  • For the URL, I used jdbc:oracle:thin:@localhost:1521:XE
  • Different username/password — I followed the instructions (also in Section 8.3.2.) for creating a user via the Oracle SQL command line
  • Commented out the mbean element

(When I first deployed this datasource, I got a stacktrace containing the following error:

Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for:


[Update 8/21/2008: I found instructions for fixing the missing ExceptionFormatter class so that this mbean no longer needs to be commented out: the class name in the code attribute needed to be corrected from to org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter.]

Now when I deploy I see:

09:29:09,112 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=XAOracleDS' to JNDI name 'java:

Added JNDI lookup to Spring bean file

I went to the Spring beans file for the Hibernate stuff and put this JNDI lookup there:

<jee:jndi-lookup id="myDataSource" jndi-name="java:XAOracleDS" />

So, now that will be there when I’m ready to try it out.

Update: Oracle JDBC driver

I was looking through some notes I had and another part of the setup, which I had done previously (besides installing Oracle Database 10g Express Edition), was to go in our Maven repository to the following location:

  • group id:
  • artifact id: ojdbc5
  • version:

and put the ojdbc5- from there in JBoss’s server\default\lib directory.

Next time we’ll configure the Hibernate session factory…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.