Win a copy of Microservices Testing (Live Project) this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

javax/mail/Message error

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a program using javamail to send email.
When i run it as a standalone program, it works and sends email.

But, when i instantiate this class in my java program and call its method to send email,
it gives me

java.lang.NoClassDefFoundError: javax/mail/Message

I have mail.jar and activation.jar in the classpath.
My doubt is, why is it executing as a stand-alone program only?
Please help.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between "run it as a standalone program" and "instantiate this class in my java program"? Both sound like a program is run from the command line, so the difference may be in how they are run (i.e., what is entered on the command line).
 
Kalai Selvi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry.. When i include it in web application(running on tomcat5), it gives out

java.lang.NoClassDefFoundError: javax/mail/Message

at runtime.

I meant it as standalone, when i gave a main method for the SendEmail.java and run it.

But, within tomcat it always says java.lang.NoClassDefFoundError: javax/mail/Message

I've checked my whole system. i have only one mail.jar
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So do you have a copy of mail.jar in the WEB-INF/lib directory of your web app?
reply
    Bookmark Topic Watch Topic
  • New Topic