aspose file tools*
The moose likes Tomcat and the fly likes Help Me : Error in sending mail from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Help Me : Error in sending mail from JSP" Watch "Help Me : Error in sending mail from JSP" New topic
Author

Help Me : Error in sending mail from JSP

Manoj Tyagi
Ranch Hand

Joined: Jun 11, 2002
Posts: 35
Dear All,

I am trying to send mail from JSP page in the following way :

try {
StringBuffer actv_msgstr = new StringBuffer();
Properties props = System.getProperties();
props.put("mail.smtp.host", "my_mail_host");
props.put("mail.smtp.port","25");
Message actv_msg = new MimeMessage(Session.getDefaultInstance(props, null));
InternetAddress[] actv_to = InternetAddress.parse("manoj.tyagi@xxxxxxxx.com");
actv_msg.setRecipients(Message.RecipientType.TO, actv_to);
actv_msg.setFrom(new InternetAddress("manoj_k_tyagi@yyyyyyy.com"));
actv_msg.setSubject("Hi");
actv_msgstr = new StringBuffer();
actv_msgstr.append("I am here too");
actv_msg.setContent(actv_msgstr.toString(),"text/plain");
Transport.send(actv_msg);
System.out.println("Joke-Mail sent to ");
out.println("Mail Sent : ");
} catch(Exception e) {
System.out.println("Error in sending joke-mail to : "+ e);
out.println("Mail Sent Error : "+e );
}

This code run perfectly fine in Tomcat 3(with jdk1.3.1), but when I try to run it in Tomcat 5(with jdk1.4.2), I get the following error :

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: com/sun/activation/registries/MailcapFile
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.whatever.manoj11_jsp._jspService(manoj11_jsp.java:141)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NoClassDefFoundError: com/sun/activation/registries/MailcapFile
javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:98)
javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:44)
javax.activation.DataHandler.getCommandMap(DataHandler.java:136)
javax.activation.DataHandler.getDataContentHandler(DataHandler.java:568)
javax.activation.DataHandler.getInputStream(DataHandler.java:222)
javax.activation.DataHandlerDataSource.getInputStream(DataHandler.java:658)
javax.mail.internet.MimeUtility.getEncoding(MimeUtility.java:102)
javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:949)
javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1608)
javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1589)
javax.mail.Transport.send(Transport.java:76)
org.apache.jsp.whatever.manoj11_jsp._jspService(manoj11_jsp.java:125)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


Is there any thing wrong in the classpath or Tomcat classpath etc. Can anybody help me out what is this problem & How can I get rid of this..

Please help me,

Thanks

Manoj
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Tomcat 5 has different rules for where commonly used jar files go. Is activation.jar in your tomcat/common/lib directory?
See the class-loader-howto.html in tomcat-docs.
Bill


Java Resources at www.wbrogden.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help Me : Error in sending mail from JSP
 
Similar Threads
How to resolve the exception? Help!
Exception in struts Application
HTTP status 500 - Unknown source
Check for Duplicates
struts exception