• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassNotFoundException: com.mysql.jdbc.Driver

 
Hector Pertierra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody

I have a BIG problem with my ANT buildfile. I'm trying to run a simple Test to connect to my app's database, but after it succesfully COMPILES and JARS itself, when it gets to EXECUTE I get the following message:

[java] org.dotcom.contab.proceso.DAOException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
[java] at org.dotcom.contab.proceso.impl.MySQLDAOFactory.<init>(Unknown Source)
[java] at org.dotcom.contab.proceso.DAOFactory.getDAOFactory(Unknown Source)
[java] at org.dotcom.contab.salida.Main.main(Unknown Source)
[java] Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
[java] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:164)
[java] at org.dotcom.contab.proceso.impl.MySQLDAOFactory.loadDriver(Unknown Source)


I know I probably have a problem with the CLASSPATH, since I'm running the app directly from the jar archive: here's the code:






I'm really really stuck, I've tried a bunch of things and I don't know what to do anymore. I read somewhere that when running a program from the jar it ignores user classpath settings, is it true??? I NEED to run it from the jar since it's one of the projects requirements...

PLEASE HELP!!!

Thanks in advance
Hector
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice that you seem to be putting third party jars into your jar file. Those other jars will *not* automatically be on the classpath!
 
Hector Pertierra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I'm aware of that, but how do I PUT them into the classpath???
 
Hector Pertierra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After fighting with the CLASSPATH for more than 24 hours, I fixed it

I had to put the JAR File next to the distribution. And set the Manifest's Class-Path to the JAR File. It finally worked. Thanks!
 
prateek urmaliya
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be It's too late
but you can try
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic