2

The Problem

Anytime I start my Tomcat server via Eclipse I always get a Class not found error:

SEVERE: Exception processing Global JNDI Resources
javax.naming.NamingException: Class not found: oracle.jdbc.xa.client.OracleXADataSource
    at org.apache.naming.factory.BeanFactory.getObjectInstance(BeanFactory.java:136)

The Setup

My server.xml file has a resource setup like:

<GlobalNamingResources>
    <Resource name="sub1" auth="Container"
              type="oracle.jdbc.xa.client.OracleXADataSource"
              factory="org.apache.naming.factory.BeanFactory"
              user="****" password="*****"
              URL="**************************************" />
</GlobalNamingResources>

context.xml has an entry that looks like so:

<ResourceLink name="dataSource/sub1" global="sub1" type="javax.sql.DataSource" /> 

On my application, I'm using Oracle's JDBC driver - classes12.jar

The Question

What do I need to fix on the Tomcat server so that it can find the appropriate class - oracle.jdbc.xa.client.OracleXADataSource. My first guess would be that classes12.jar needs to be copied to a folder somewhere on the server. I'm not even totally sure where the folder on Windows for Eclipse... any help would be appreciated.

Thanks!

John Strickler
  • 25,151
  • 4
  • 52
  • 68

5 Answers5

5

Assuming Tomcat 6, the required library needs to be copied to $CATALINA_HOME\lib.

From the Tomcat documentation on setting up JDBC DataSources:

1. Install Your JDBC Driver

Use of the JDBC Data Sources JNDI Resource Factory requires that you make an appropriate JDBC driver available to both Tomcat internal classes and to your web application. This is most easily accomplished by installing the driver's JAR file(s) into the $CATALINA_HOME/lib directory, which makes the driver available both to the resource factory and to your application.

Also, I would avoid using classes12.zip. It is meant to be used in Java 1.2 and 1.3 runtime environments only. Use ojdbc14.jar if you are stuck with Java 1.4. Or use the recommended ojdbc6.jar/ojdbc5.jar for the Java 6 or Java 5 environments.

Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
2

The simplest fix, assuming that OracleXADataSource is a class in classes12.jar, is to copy that JAR into Tomcat's lib directory.

  • Tomcat 5: $CATALINA_HOME/common/lib
  • Tomcat 6: $CATALINA_HOME/lib
Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
1

Not classes12.jar; that's JDK 1.2 vintage. Your Oracle JDBC driver JAR ought to match your JDK and Oracle versions (e.g. ojdbc16.jar for JDK 1.6).

Put that in your Tomcat /server/lib for Tomcat version 5.x and /lib for Tomcat version 6.x and higher.

I'd also recommend not altering your server.xml file. Better to put that information in your project's META-INF/context.xml file.

duffymo
  • 305,152
  • 44
  • 369
  • 561
0

From the documentation:

Drivers for older Oracle versions may be distributed as *.zip files rather than *.jar files. Tomcat will only use *.jar files installed in $CATALINA_HOME/lib

So yes, you have to put the jar in $CATALINA_HOME/lib

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0

Copy the classes12.jar in tomcat's /common/lib directory .

Srikanth Venkatesh
  • 2,812
  • 1
  • 20
  • 13