Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Help Me : Error in sending mail from JSP

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Can't .... do .... plaid .... So I did this tiny ad instead:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic