java.lang.ClassNotFoundException
Hi, i need help with this problem, im getting this exception:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver in this line: Class.forName("oracle.jdbc.driver.OracleDriver");
this is the complete list of errors reported:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at ConexionBD.<init>(ConexionBD.java:36)
at TFSTimer.run(TFSTimer.java:266)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
ex.getCause()= null
ex.getMessage()= oracle.jdbc.driver.OracleDriver
ex.getException()= null
java.lang.NullPointerException
at ConexionBD.<init>(ConexionBD.java:58)
at TFSTimer.run(TFSTimer.java:266)
at java.util.TimerThread.mainLoop(Timer.java:432)
at java.util.TimerThread.run(Timer.java:382)
* Im using Apache Tomcat and JCreator,
* Ive this libraries in WEB-INF/lib of the project: ojdbc14.jar, sqljdbc.jar, classes111.jar and classes12.jar.
* The classpath in JCreator is:
C:\j2sdk1.4.2\jre\lib\rt.jar;C:\j2sdk1.4.2\lib\dt.jar;C:\j2sdk1.4.2\lib\tools.jar;C:\j2sdk1.4.2\jre\lib\ext\dnsns.jar;C:\j2sdk1.4.2\jre\lib\ext\ldapsec.jar;C:\j2sdk1.4.2\jre\lib\ext\localedata.jar;C:\j2sdk1.4.2\jre\lib\ext\sunjce_provider.jar;C:\Archivos de programa\Apache Software Foundation\Tomcat 6.0\webapps\Estadisticas\WEB-INF\lib;C:\Archivos de programa\Apache Software Foundation\Tomcat 6.0\webapps\Estadisticas;C:\oracle\ora92\jdbc\lib
Thanks for advance.
# 1
I believe to solve this:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver in this line: Class.forName("oracle.jdbc.driver.OracleDriver");
Get rid of all these jar files except ojdbc14.jar
Ive this libraries in WEB-INF/lib of the project: ojdbc14.jar, sqljdbc.jar, classes111.jar and classes12.jar.
If you have a datasource tag in tomcat's server.xml or context.xml file, tomcat looks for any jar file that implements the datasource interface and I believe it uses whatever jar file it comes across first that implements it. All those jar files implement datasource. If it comes across sqljdbc.jar first, then it uses that datasource (which isn't an oracle driver) and ignores the datasource implemented in ojdbc14.jar.
The other jar files just duplicates what odjbc14.jar does.
Last point: try to pick a login name that isn't your first and last name. That way, you can insult people on-line anonymously ;)
# 2
> I believe to solve this:
> java.lang.ClassNotFoundException:
> oracle.jdbc.driver.OracleDriver in this line:
> Class.forName("oracle.jdbc.driver.OracleDriver");
>
> Get rid of all these jar files except ojdbc14.jar
> Ive this libraries in WEB-INF/lib of the project:
> ojdbc14.jar, sqljdbc.jar, classes111.jar and
> classes12.jar.
Do get rid of all those other JARs, but that won't fix the problem.
You have a fundamental misunderstanding of Tomcat. I don't recall now if you said which version of Tomcat you have (5? 6?), but the JDBC JAR belongs in server/lib for Tomcat 5 and wherever the docs say you should put it for Tomcat 6. OR, you can put it in the WEB-INF/lib of your web app. (The docs say no, but I've had this work in the past.)
You're learning another lesson: Tomcat doesn't give a fig about your system environment variable CLASSPATH. It totally ignores it, as does every Java EE app server and every IDE that I know of. There's little reason for it anymore, IMO. (I don't have one on any machine that I use.)
The harm of it is that you get a false sense of security: "See? My CLASSPATH is set."Get rid of it.
%