This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Modern JavaScript for the Impatient and have Cay Horstmann on-line!
See this thread for details.
Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

java.lang.NoClassDefFoundError: javax/mail/MessagingException?

 
Gunslinger
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so, I have Googled this extensively, but still not sure what I'm doing wrong.

My program does reference javax.mail.*, and I only get the error when running from the command line (otherwise, do not get it);

So I have downloaded javamail 1.4.3 and put mail.jar and smtp.jar in the C:\Program Files\Java folder, then added:

C:\Program Files\Java\mail.jar;C:\Program Files\Java\smtp.jar to my environment variables string.

If interested, my entire CLASSPATH string is: C:\Program Files\VERITAS\Backup Exec\NT\ECM\bumodule.jar;C:\Program Files\VERITAS\Backup Exec\NT\ECM\LOG4J-CORE.JAR;C:\Program Files\VERITAS\Backup Exec\NT\ECM\LOG4J.JAR;C:\Documents and Settings\inforadmin.PASCOUTIL\My Documents\NetBeansProjects\CMMS_SCADA\src\cmms_scada;.;C:\Program Files\java\mail.jar;C:\Program Files\java\smtp.jar;

This didn't work, and I even added the .jar files explicitly to my library in NetBeans. Still no-go. I don't think the code is necessary for anyone to help, but I can post it, if desired. I'm just scratching my head on this one. Anyone???

As always, thank you in advance!!!
 
Marshal
Posts: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Brooks wrote:So I have downloaded javamail 1.4.3 and put mail.jar and smtp.jar in the C:\Program Files\Java folder, then added:

C:\Program Files\Java\mail.jar;C:\Program Files\Java\smtp.jar to my environment variables string.



For a start, don't do that. Only put mail.jar into your classpath. The smtp.jar is a subset of mail.jar, which just confuses things. (The idea for a subset of JavaMail which only supported SMTP dates back to the time in the Dark Ages when a 200KB download was a heavy burden for an applet. Now that applets are not the main target of JavaMail and downloading a 200KB jar isn't a big deal, that idea is dead.)
 
James Brooks
Gunslinger
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the suggestion. I removed SMTP.jar from my CLASSPATH, and it still occured. Any other ideas?
 
Paul Clapham
Marshal
Posts: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see you didn't add the Java Activation Framework to your classpath, so presumably you're using Java 6 where it is built in?

And do any of those other jars contain JavaMail classes?

Also, the stack trace would be useful information, to see where the class is being requested from.
 
James Brooks
Gunslinger
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, jdk1.6 and jre6. And sorry, which other jars are you referring to?


Stack trace:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingE
xception
at cmms_scada.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more

Paul Clapham wrote:I see you didn't add the Java Activation Framework to your classpath, so presumably you're using Java 6 where it is built in?

And do any of those other jars contain JavaMail classes?

Also, the stack trace would be useful information, to see where the class is being requested from.

 
James Brooks
Gunslinger
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, should I take the mail jar out of my project's library in Netbeans, since I'm putting them in the CLASSPATH variable in my WS2003 machine?
 
Paul Clapham
Marshal
Posts: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know anything about Netbeans. I assume that taking mail.jar out of there will very quickly have a noticeable effect if it's the wrong thing to do, though.

As far as this problem is concerned, you should make sure that you don't have anything in your JRE extensions directory. Classes loaded from there can't load other classes which are in the regular classpath.
 
Greenhorn
Posts: 25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try to include mail.jar in your server lib directory.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works! Thanks
    Bookmark Topic Watch Topic
  • New Topic