aspose file tools*
The moose likes Websphere and the fly likes NoClassDefFoundError JavaMail.......... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "NoClassDefFoundError JavaMail.........." Watch "NoClassDefFoundError JavaMail.........." New topic
Author

NoClassDefFoundError JavaMail..........

karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34

The error when I'm trying to send a mail in my servlet application is...

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/activation/registries/LogSupport
at javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:111)
at javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:44)
at javax.activation.DataHandler.getCommandMap(DataHandler.java:136)
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:567)
at javax.activation.DataHandler.writeTo(DataHandler.java:294)
at javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:230)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1065)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1923)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1904)
at javax.mail.Transport.send(Transport.java:79)
at JavaMail.send(JavaMail.java:21)
at JavaMail.main(JavaMail.java:26)


Can anyone please help out.

Regards
Karthik
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
This was the code written....

arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3223
Check if you have the Java Activation Framework jar file in your classpath. If not, download and add it to your classpath.


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
hey,

I did add the activation.jar to my class path but still it persists....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

This class should be part of rt.jar from the default JRE installation, at least if you use Java 6 (probably Java 5.0 as well). Which JRE are you using?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
version 5.0
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
"This class should be part of rt.jar"

I'm using RAD.... so how do i include the activation.jar as part of rt.jar......

If you don't mind could you please explain...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
karthik mama wrote:I did add the activation.jar to my class path but still it persists....

How did you add the file, and how are you running this code?


Ping & DNS - my free Android networking tools app
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34

Right clicking my project and selecting build path i included the activation.jar files.....this was what i did....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

karthik mama wrote:"This class should be part of rt.jar"

I'm using RAD.... so how do i include the activation.jar as part of rt.jar......

If you don't mind could you please explain...

You don't need to add activation.jar as part of rt.jar. They just have to be both part of the class path; rt.jar usually is by default - if not the JVM can't even find java.lang.Object.


I've just checked a Java 5.0 installation, and it is missing this class inside rt.jar. That's because the activation framework wasn't part of the core API until Java 6. It's inside activation.jar though, so it seems you haven't added it properly to the class path.


How did you run your application when you got this exception? From within RAD, or from the command line? Because the latter requires you to set the class path yourself.
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
I ran it on websphere app server 6.x ....
so you want me to also include rt.jar??
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

No, that's already included by default.

Did you add activation.jar to your Websphere class path? Just adding it in RAD is not enough for deploying.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

This looks like a version conflict to me. But Websphere already includes mail.jar and activation.jar in its system classpath (you can confirm this with the "snoop" servlet) so you don't need to put either in your application. And you shouldn't, either. Providing a different version than the one Websphere provides can lead to version conflicts.
karthik mama
Ranch Hand

Joined: Aug 27, 2007
Posts: 34
how to add it to websphere class path by the way??

And after removing mail.jar and activation.jar as you said the errors followed.....

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
at JavaMail.send(JavaMail.java:14)
at JavaMail.main(JavaMail.java:26)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError JavaMail..........