- This topic has 6 replies, 2 voices, and was last updated 19 years ago by
Kalle-lumi.
-
AuthorPosts
-
Kalle-lumiMemberHi,
I am trying to send mail from jsp and I get:
The type javax.mail.MessagingException cannot be resolved. It is indirectly referenced from required .class filesDo I need to download mail.jar and activation.jar and put them in the classpath?
Thanks in advance 🙂
*** Date: Wed Apr 26 19:31:10 CEST 2006
*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_06*** MyEclipse details:
MyEclipse Enterprise WorkbenchVersion: 4.1.1 GA
Build id: 20060309-4.1.1-GA*** Eclipse details:
Eclipse SDKVersion: 3.1.2
Build id: M20060118-1600Eclipse Platform
Version: 3.1.2
Build id: M20060118-1600Eclipse RCP
Version: 3.1.2
Build id: M20060118-1600Eclipse Java Development Tools
Version: 3.1.2
Build id: M20060118-1600Eclipse Plug-in Development Environment
Version: 3.1.2
Build id: M20060118-1600Eclipse Project SDK
Version: 3.1.2
Build id: M20060118-1600Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\Program\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
808_2c
-vm
C:\WINDOWS\system32\javaw.exe////////////////////////////////////
//Here is my MailSender.java
////////////////////////////////////package org.branemark.webshop;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.*;public class MailSender {
public void postMail(String smtpsrv, String recipients[], String subject,
String message, String from) throws MessagingException {boolean debug = false;
// Set the host smtp address
Properties props = new Properties();
props.put(“mail.smtp.host”, smtpsrv);// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);InternetAddress[] addressTo = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, “text/html;charset=utf-8”);
Transport.send(msg);
}}
/////////////////////////
//and here is my jsp
////////////////////////<%
if(session.getAttribute(“uid”) != null) { // only accept logged in users
MailSender mailSender = new MailSender();
try {
String recipients[] = {“goran_celion@yahoo.se”};
mailSender.postMail(“mailrelay.whatever.com”, recipients, “Thank you for your order with whatever.org”, “Pay us 1000 EUR instantly!!!”, “whatever.org – Web shop”);
} catch (MessagingException e1) {
e1.printStackTrace();
}
%>
<body>
Thank you for your order
</body>
Riyad KallaMemberDo I need to download mail.jar and activation.jar and put them in the classpath?
Yes definately, these need to go in your WEB-INF/lib dir and deploy with your project. I had the same problem on a project when I was forgetting to deploy the JavaMail JARs with the app.
Kalle-lumiMemberI am afraid it doesn’t work
I put them in C:\BranemarkEclipseWorkspace\branemark\WebRoot\WEB-INF\lib
Tried to add that path to the Java build path in Projects settings but it doesnt help
(Ooh I am so worried about my project dead line on Friday)
Any other ideas? 🙂
Riyad KallaMemberTried to add that path to the Java build path in Projects settings but it doesnt help
After you copied the JARs into the WEB-INF/lib dir, MyEclipse should have added them automatically to your Java Build Path > Libraries tab, if it didn’t, go there now and click “Add JAR” then navigate down to your WEB-INF/lib dir and add them.
NOTE: If you copied the JARs in using an external method, you will need to refresh your project so Eclipse can see the files (right click on root, and do a Refresh).
Also you need to redeploy your project, make sure to do that.
Kalle-lumiMemberHm something changed 🙂 but the new exception I simply can’t explain (see below)
In orderAcknowledgement_action.jsp I am calling for MailSender via “import org.branemark.org” which is located in that same package. (see my first message in this forum thread)
/kalle-lumi
2006-apr-27 08:21:58 org.apache.catalina.core.StandardWrapperValve invoke
ALLVARLIG: Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: javax/mail/Message
at org.apache.jsp.webshop.orderAcknowledgement_005faction_jsp._jspService(org.apache.jsp.webshop.orderAcknowledgement_005faction_jsp:54)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
Riyad KallaMemberKalle-Lumi,
If you are already including the mail and activation JARs, double check that your Server doesn’t already ship these in it’s /lib dir. I understand you have a deadline tommorow, but this problem is a run of the mill missing class issue, I hope you realize this has nothing to do with MyEclipse and I am helping you as a curteosy. You need to do more digging yourself and hunting my friend.
Kalle-lumiMemberYes I realize that Riyad. I appreciate your effort very much. Thanks.
I will do the rest now. Cheers 🙂/kalle-lumi – digging & hunting
-
AuthorPosts