www.jarhoo.com is your friend to find missing jar files libraries

C.F. Scheidecker Antunes wrote:

Hello,

Thanks for the info. I am still having problems sending email from a struts action.

I've created a separate class emailClient to send the message. The class is on the end
of the email.

I have mailapi.jar under /WEB-INF/lib/ version 1.3.3.01 <http://1.3.3.01> but nothing works.
Here's the exception I am getting:

*exception*

javax.servlet.ServletException: Servlet execution threw an exception
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)

*root cause*

java.lang.NoClassDefFoundError: javax/activation/DataSource
    com.nando.utils.emailClient.doSend(emailClient.java:43)
    com.nando.struts.action.TestAction.send2Mail(TestAction.java:51)
    com.nando.struts.action.TestAction.execute
(TestAction.java:77)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
    org.apache.struts.action.ActionServlet.process
(ActionServlet.java:1194)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet.java
:802)
org.securityfilter.filter.SecurityFilter.doFilter(SecurityFilter.java:188)



*import* java.util.*;

*import* javax.mail.*;
*import* javax.mail.internet.*;
*import* javax.mail.MessagingException;

*public* *class* emailClient {
*private* *Properties* props; *protected* Session session;
    *protected* Message msg;

    /// default constructor/
    *public* emailClient() {
} *public* void doSend(*String* From, *String* To, *String* *Subject*, *String* Body) { props = *new* *Properties*();
        props.put("smtp.nando.com","mailhost");
/// Create the session object/
        session = Session.getDefaultInstance(props,*null*);
        session.setDebug(*true*);
*try* {
            msg = *new* MimeMessage(session);
/// From/
            InternetAddress fromAddress = *new* InternetAddress(From);
            msg.setFrom(fromAddress);
/// To address/
            InternetAddress toAddress = *new* InternetAddress(To);
            msg.addRecipient(Message.RecipientType.TO, toAddress);

            /// Subject/
            msg.setSubject(*Subject*);
/// Body/
            msg.setText(Body);
/// send the message/
            Transport.send(msg);
        }

        *catch* (MessagingException ex) {
*while* ((ex = (MessagingException)ex.getNextException()) != *null*) {
                ex.printStackTrace();
            }
        }
    }

}

On the action I create an emailClient object and call doSend with the params.
It crashes as the messages above.

Borislav Sabev wrote:



java.lang.NoClassDefFoundError: javax/mail/Message
    com.nando.struts.action.TestAction.send1Mail(TestAction.java:35)
    com.nando.struts.action.TestAction.execute(TestAction.java:69)



Seems that you don't have mail.jar in WEB-INF/lib.

borislav

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to