Hello,
I've tried this before, even I've tried to uncompress the "mail.jar"
file into the /WEB-INF/classes directory of my webapp, stoping and starting
the service and it doesn�t work.
The better thing about all of this, is that a simple mail application,
that uses the Javamail interface, work whitout problems.
I'm using the following includes:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.activation.*;
import javax.mail.internet.*;
And the (simple) Servlet code:
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String strMail = "";
try { strMail = request.getParameter("EMail"); } catch (Exception e) {
e.printStackTrace(); }
Properties props = System.getProperties();
props.put("mail.smtp.host", "mail.host.xx");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
Message msg = new MimeMessage(session);
try {
msg.setSubject("Este es el tema del mensaje");
msg.setFrom(new InternetAddress("[EMAIL PROTECTED]") );
msg.setText("Hello World!");
msg.setRecipients( Message.RecipientType.TO,
InternetAddress.parse(strMail,true) );
}
catch (MessagingException e) {
e.printStackTrace();
}
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
out.println("<html>");
out.println("<head><title>Correo</title></head>");
out.println("<body>");
out.println("<p>Message to: " + strMail + "</p>");
try {
out.println("<p>Tema: " + msg.getSubject() + "</p>");
Transport.send(msg);
out.println("<p>Mensaje enviado a " + strMail + " con �xito!</p>");
}
catch (MessagingException e) {
e.printStackTrace();
}
out.println("</body></html>");
out.close();
}
I hope this can help.
Thanks,
Gustavo Comba
-----Original Message-----
From: Sam Newman <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: jueves 26 de abril de 2001 13:44
Subject: Re: Problem with Javamail
>I would guess the relevent jar (the ajva mail jar file) isn;t in the
>WEB-INF/lib directory of your webapp.
>
>sam
>----- Original Message -----
>From: "Gustavo Comba" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Thursday, April 26, 2001 12:17 PM
>Subject: Problem with Javamail
>
>
>> Hello,
>>
>> I'm trying Apache-SOAP Version 2.1 over Tomcat 3.2.1.
>>
>> I've written a simple Servlet that send e-mails using the Sun's
>JavaMail
>> implementation without any problem, but I cant get the SOAP running (even
>> the sample servlets included with the implementation).
>>
>> I'm getting the following error:
>>
>> java.lang.NoClassDefFoundError: javax/mail/MessagingException
>> at pruebas.Correo.doPost(Correo.java:71)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>> at
>org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:401)
>> at org.apache.tomcat.core.Handler.service(Handler.java:286)
>> at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>> at
>>
>org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:7
9
>> 7)
>> at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>> at
>>
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Http
C
>> onnectionHandler.java:210)
>> at
>> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>> at
>>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>> at java.lang.Thread.run(Thread.java:484)
>>
>> I've checked the Apache SOAP documentation about the install using
>> Tomcat. I'm running Tomcat as NT Service, and I've modified the class
path
>> in wrapper.properties as following.
>>
>> wrapper.class_path=$(wrapper.java_home)\jre\lib\ext\xerces.jar
>> wrapper.class_path=$(wrapper.java_home)\jre\lib\ext\xml4j.jar
>> wrapper.class_path=$(wrapper.java_home)\jre\lib\ext\soap.jar
>> wrapper.class_path=D:\Utils\JAVA\Sun\javamail-1.2\mail.jar
>> wrapper.class_path=D:\Utils\JAVA\Sun\jaf-1.0.1\activation.jar
>>
>> (the first three lines are useless, I think)
>>
>> Then, I've tried running Tomcat from the command line, using
>> "startup.bat". I've modified "tomcat.bat" as following:
>>
>> set
>>
>CLASSPATH=C:\jdk1.3\jre\lib\ext\xerces.jar;D:\Utils\JAVA\Sun\javamail-1.2\m
a
>> il.jar;D:\Utils\JAVA\Sun\jaf-1.0.1\activation.jar;%CP%
>>
>> in place of "set CLASSPATH=%CP%"....
>>
>> And nothing!!! What I'm doing wrong?
>>
>> If is some usefull information missing in my message, please let me
>> know.
>>
>> Thanks in advance, and please forgive my horrible English! ;-)
>>
>> Gustavo Comba
>>
>>
>
>