OracleDriver load fails from a Web Service On tomcat

J

jaja

Hello,
I have built a web service in eclipse.

From one service, all I do is

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

But then I get the following exception:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1340)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1189)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)... etc...

I use Oracle 9.x, I have classes12.zip in my class path, I tries to
change it to classes12.jar, I tried to put it under tomcat local
directory and to point the path to there, but nothing worked.

Interesting is the fact that if I run the same code exactly outside
the web service method, for example from the test class main function,
everything is fine. So I suspect it is a configurable issue. But what
is it???

Thanks!
 
M

Manish Pandit

Hello,
I have built a web service in eclipse.

From one service, all I do is

try {
Class.forName("oracle.jdbc.driver.OracleDriver");} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block
e.printStackTrace();

}

But then I get the following exception:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1340)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1189)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)... etc...

I use Oracle 9.x, I have classes12.zip in my class path, I tries to
change it to classes12.jar, I tried to put it under tomcat local
directory and to point the path to there, but nothing worked.

Interesting is the fact that if I run the same code exactly outside
the web service method, for example from the test class main function,
everything is fine. So I suspect it is a configurable issue. But what
is it???

Thanks!

Put classes12.jar in $TOMCAT_HOME/lib/ext and bounce Tomcat.

Do not change the extension to jar.

-cheers,
Manish
 
M

Manish Pandit

Put classes12.jar in $TOMCAT_HOME/lib/ext and bounce Tomcat.

Do not change the extension to jar.

-cheers,
Manish

Oops! My bad. I mistook Tomcat for JMeter. You can put classes12.jar
in $TOMCAT_HOME/common/lib and then bounce Tomcat.

-cheers,
Manish
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

jaja said:
I have built a web service in eclipse.

From one service, all I do is

But then I get the following exception:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
I use Oracle 9.x, I have classes12.zip in my class path, I tries to
change it to classes12.jar, I tried to put it under tomcat local
directory and to point the path to there, but nothing worked.

Interesting is the fact that if I run the same code exactly outside
the web service method, for example from the test class main function,
everything is fine. So I suspect it is a configurable issue. But what
is it???

I don't think Tomcat are using your CLASSPATH environment variable.

Try put the zip file in yourwebapp/WEB-INF/lib and restart the web app.

In general: never use the CLASSPATH environment variable.

Arne
 
L

Lew

Manish said:
Oops! My bad. I mistook Tomcat for JMeter. You can put classes12.jar
in $TOMCAT_HOME/common/lib and then bounce Tomcat.

Incidentally, classes12.jar is for Java 1.2 - pretty ancient, considering that
Java 1.3 is already obsolete and Java 1.4 is obsolescent. Consider upgrading
to a current Oracle JDBC driver.
 
G

Guest

Lew said:
Incidentally, classes12.jar is for Java 1.2 - pretty ancient,
considering that Java 1.3 is already obsolete and Java 1.4 is
obsolescent. Consider upgrading to a current Oracle JDBC driver.

Oracle 9i was first released in 2001. Java 1.4 was first released
in 2002. I don't think Oracle released a Java 1.3 version (probably
because there were no changes to JDBC in that release).

So the 1.2 version could be the newest supported for that
database version.

The risk of running a new JDBC driver with an old database
seems much greater than running an old JDBC driver with a
new Java.

Arne
 
J

Juha Laiho

=?UTF-8?B?QXJuZSBWYWpow7hq?= said:
Oracle 9i was first released in 2001. Java 1.4 was first released
in 2002. I don't think Oracle released a Java 1.3 version (probably
because there were no changes to JDBC in that release).

So the 1.2 version could be the newest supported for that
database version.

According to Oracle, that is not the case. There's a statement about
this in the Oracle Database JDBC Developer's Guide and Reference:
http://download-uk.oracle.com/docs/cd/B19306_01/java.102/b14355/getsta.htm#i1008205
and a cross-compatibility list in the Oracle JDBC FAQ:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#02_02

I've been using both a 10g JDBC driver against an 8.1.7 db,
and vice versa. And as with software in general, amount of
bugs does vary with versions - newest isn't always the best,
but the oldest might not be, either. Find a version that works
for your particular case, and be alert whenever you have to
migrate from the "known working" version.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top