4
votes

I have installed a third party java webservice which uses Oralce jdbc thin driver to write data into Oracle database. When i run this, i get the following error;

JDBC Driver class not found: oracle.jdbc.OracleDriver

I have oracle installed and set classpath variable to following value:

*D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip;C:\Program Files\Java\jdk1.7.0\jre\lib\rt.jar*

and path variable to following value;

*D:\oracle\product\10.2.0\client_1\bin;C:\Program Files\Java\jdk1.7.0\bin\;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\classes12.zip;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;D:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip*

Any suggestion why web service is not able to identify jdbc driver?

Thanks

5
How exactly are you executing the web service? - BalusC
How/where do you register the oracle driver (and copy/paste the exact error message and stacktrace you are getting) - nos
@BalusC: I'm executing it was windows service. This is actually provided by third party vendor. I just updated the config file with database connection string and run the service - Phoenix
@nos: I got this error message: <log4j:message><![CDATA[JDBC Driver class not found: oracle.jdbc.OracleDriver]]></log4j:message>. - Phoenix
It's hard to post an answer as long as we know nothing about that web service. At least, you should not confuse PATH with CLASSPATH. The operating system platform-specific PATH environment variable has nothing to do with classpath. It should represent a collection of disk file system paths where the operating system has to look for executabeles. The Java-specific CLASSPATH environment variable is only used by Java and it represent a collection of disk file system paths where Java has to look for classes. - BalusC

5 Answers

2
votes

I know 2 ways of turning Java app into Windows service and both do not use CLASSPATH. One is Java Service Wrapper by Tanuki Software. This tool uses wrapper.conf where you can show directories with .jar libraries:

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=c:\jars\*
wrapper.java.classpath.2=myservice.jar

Second tool I know is JSL: Java Service Launcher. In this tool there is jsl.ini where you put command line to run your server. It can use java with -cp option to show location of .jar libraries:

[defines]
MY_LIBS=d:\jars\*
AXIS_LIBS=d:\axis2-1.5.4\lib\*
CLASSPATH=.;%MY_LIBS%;%AXIS_LIBS%
export = CLASSPATH
...

[java]
...
cmdline = -Dfile.encoding=utf8 -cp %CLASSPATH% example.my.server

In both configuration you can use * to add all .jar files or you can show those files one by one (just like in CLASSPATH).

At first you should know what Windows is trying to execute. Check it in the service properties page. Then try to localize its configuration. If it uses one of tools I know then you know what to change. Other tools probably have similar configuration.

1
votes

Method 1: Download ojdbc.jar

add ojdbc6.jar to deployment assembly. Right click on project->properties->select deployment assembly->click on 'Add' ->select 'Archives from File System'->browse to the folder where ojdbc6.jar is saved.->add the jar->click finish->Apply/OK.

Method 2:

if you want to add ojdbc.jar to your maven dependencies you follow this link: http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ . . Even if you're using a maven project it is not necessary to add ojdbc to maven dependencies(method 2), method 1 (adding directly to deployment assembly) works just fine.

0
votes

Make sure you have the ojdbc jar file (make sure you are using the correct one because depending on java version you may need to choose a different one).

use ojdbc14.jar for Java 1.4 use ojdbc5.jar for Java 1.5 ojdbc6.jar for Java 1.6 here is linke where you can download ojdbc6.jar file http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html

0
votes

You also have to add the jdbc jar to your server classpath. if tomcat, rigth-click on your Project->run as->run configurations, click on classpath and add your jdbc jar in Add external jars option

0
votes

add ojdbc-6.jar to your lib directory of tomcat installation. Maven will downlowd this jar for you in .m2 directory, but you need to have this jar in tomcat lib as well.