Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Send Email using Servlet

 
Amey Ambulgekar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello java friend ,

currently i am working on java mail. I am trying to send email using servlet but i am facing lots of problems.

A normal Stand alone java mail program works.

But, if i embedded it in servlet application i got various errors even i have added all jars in it.

Here is my servlet program and my exceptions

Servlet Program ::


and here are the Exceptions i got ::



HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Error instantiating servlet class emailpckg.EmailServlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)


root cause

java.lang.NoClassDefFoundError: javax/mail/MessagingException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)


Please help me friends. You may run my program on your system and tell me if you are facing problems or not .?

It requires in my project so only because of this email program i am not able to submit my project.!

Thanking you.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoClassDefFoundError: javax/mail/MessagingException

This means that you are missing the class javax.mail.MessagingException.

You'll have to include the required JAR files in the WEB-INF/lib directory of your web application, just like you put them on the classpath for a standalone application.
 
Amey Ambulgekar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:java.lang.NoClassDefFoundError: javax/mail/MessagingException

This means that you are missing the class javax.mail.MessagingException.

You'll have to include the required JAR files in the WEB-INF/lib directory of your web application, just like you put them on the classpath for a standalone application.



Hello Jesper de Jong,

if it is so they why my normal Standalone Program means without using Servlet is running.?

It should have also given such error('s). But it works fine only i have problem is, when i embedded with Servlet it gives me error.!

I have included all jars such as javaee-api-6.0.jar , mail.jar,smtp.jar,pop3.jar,activation.jar,mailapi.jar,dsn.jar,imap.jar..

Why don't you tried my program please.!

 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To run your standalone program you have to set up your classpath correctly. To run your servlet you have to set up your web application correctly. This has nothing to do with the code and everything to do with configuration. So it's perfectly possible to get one right and one wrong, and you've done that.

So whining for us to run your code is not useful, since it's the configuration which is the problem, not the code, and you haven't shown us your configuration.

If you're wondering what configuration I'm talking about, well, Jesper already told you what to do. It sounds like you decided to reject that advice and post that last unfortunate post instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic