This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Tomcat and the fly likes javamail error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "javamail error" Watch "javamail error" New topic
Author

javamail error

Nirmal JeyaChandra
Greenhorn

Joined: Aug 31, 2005
Posts: 25
I am using Tomcat 5.0.28 version

My path settings are

path=C:\jdk1.4\bin;c:\tomcat\bin;.;

classpath=c:\tomcat\common\lib;c:\jdk1.4\lib;.;c:\tomcat\common\lib\servlet-api.jar;C:\tomcat\common\lib\jsp-api.jar;c:\tomcat\commons-el.jar;c:\tomcat\common\lib\jasper-compiler.jar;c:\tomacat\common\lib;c:\tomcat\server\lib;c:\jdk1.4\lib\xercesImpl.jar;c:\java\activation\activation.jar;c:\java\mail\mail.jar;c:\java\xerces\xerces.jar;

J2EE_HOME=c:\j2sdkee1.2.1

JAVA_HOME=c:\jdk1.4

I am using activation.jar (version jaf-1_0_2-upd2), mail.jar (version javamail-1_4-ea), xerces.jar (version Xerces-J-bin.1.4.4)


My program is

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import javax.mail.*;

import javax.mail.internet.*; // important

import javax.mail.event.*; // important

import java.net.*;

import java.util.*;

public class servletmail extends HttpServlet

{

public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException

{

PrintWriter out=response.getWriter();

response.setContentType("text/html");

try

{

Properties props=new Properties();

props.put("mail.smtp.host","mpkmail.eng"); // 'localhost' for testing

Session session1 = Session.getDefaultInstance(props,null);

String s1 = request.getParameter("text1"); //sender (from)

String s2 = request.getParameter("text2");

String s3 = request.getParameter("text3");

String s4 = request.getParameter("area1");

Message message =new MimeMessage(session1);

message.setFrom(new InternetAddress(s1));

message.setRecipients

(Message.RecipientType.TO,InternetAddress.parse(s2,false));

message.setSubject(s3);

message.setText(s4);

Transport.send(message);

out.println("mail has been sent");

}

catch(Exception ex)

{

System.out.println("ERROR....."+ex);

}

}

}

my output is


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 servletmail
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:536)


root cause

java.lang.NoClassDefFoundError: javax/mail/Message
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:1576)
java.lang.Class.getConstructor0(Class.java:1748)
java.lang.Class.newInstance0(Class.java:266)
java.lang.Class.newInstance(Class.java:249)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:536)


Thanks in advance. Please help me if possible.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Try copying javamail.jar to your app's WEB-INF/lib directory.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
GeeCON Prague 2014
 
subject: javamail error