• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassNotFoundException: com.mysql.jdbc.Driver

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be It's too late
but you can try
 
reply
    Bookmark Topic Watch Topic
  • New Topic