Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help Me : Error in sending mail from JSP

 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic