• 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Send Email using Servlet

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.!

 
Marshal
Posts: 26750
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic