aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes java.lang.NoClassDefFoundError:  javax/mail/MessagingException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "java.lang.NoClassDefFoundError:  javax/mail/MessagingException?" Watch "java.lang.NoClassDefFoundError:  javax/mail/MessagingException?" New topic
Author

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

James Brooks
Gunslinger
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
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!!!


Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

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
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
Thank you for the suggestion. I removed SMTP.jar from my CLASSPATH, and it still occured. Any other ideas?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

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
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
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
Ranch Hand

Joined: Aug 17, 2006
Posts: 165
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
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

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.
Gaurav Sainii
Greenhorn

Joined: May 18, 2009
Posts: 24
Please try to include mail.jar in your server lib directory.
Govindharaj Varadharajan
Greenhorn

Joined: Jan 18, 2010
Posts: 2
It works! Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NoClassDefFoundError: javax/mail/MessagingException?