Javax.mail jar compilation error
Dear friends,
I have created a DC which manages emails to users which uses the following import statements
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
i downloaded the javax.mail package which was supposed to contain the needed jars and added it to the DC ( preferences->add ext libraries->)
But i still find errors in the code.......
Did i import the right package or should the jars be added in another way??
Thanks and regards
SantoshKumar
Thanks for your response Levy, can u please help me in which folder under /eclipse/plugins does that jar file exist and by what name?
We are using JDK 1.4.2_16 and NWDS 7.0.0 and the portal server is on 1.4.2_12 and EP7.0 SP15 does this cause problem because we are facing a classversion error on deployment. What version of JDK is preferable to our environment??
Thanks and regards
SantoshKumar A
Similar Messages
-
Hi,
I am building javax.mail.jar using with the source of "JavaMail 1.4.4 source code", downloaded from http://kenai.com/projects/javamail/downloads , we have some customized changes in few source java files (regarding IMAP and response) of this source, otherwise no changes we have done in this source for building mail jar with maven.
I was using Maven 2.2.1 - successfully downloaded repository on my systems when I had Java 1.6. Then I have moved to java 7 but it failed, on roll back changes I was unable to download repositories as I had downloaded at earlier stage.
System has set JAVA_HOME of Java Home directory
[ERROR] BUILD ERROR
[INFO] ----------------------------------------------------------------------
[INFO] Internal error in the plugin manager executing goal 'com.sun.enterprise:osgiversion-maven-plugin:0.4.11:compute-osgi-version': Unable to load the mojo 'com.sun.enterprise:osgiversion-maven-plugin:0.4.11:compute-osgi-version' in the plugin 'com.sun.enterprise:osgiversion-maven-plugin'. A required class is missing: Lorg/apache/maven/shared/osgi/Maven2OsgiConverter;
org.apache.maven.shared.osgi.Maven2OsgiConverter
[INFO] ----------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionExcep tion: Internal error in the plugin manager executing goal 'com.sun.enterprise:osgiversion-maven-plugin:0.4.11:compute-osgi-version': Unable to load the mojo 'com.sun.enterprise:osgiversion-maven-plugin:0.4.11:compute-osgi-version' in the plugin 'com.sun.enterprise:osgiversion-maven-plugin'. A required class is missing: Lorg/apache/maven/shared/osgi/Maven2OsgiConverter;
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoals(DefaultLifecycleExecutor.java:698)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoalWithLifecycle(DefaultLifecycleExecuto r.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoalAndHandleFailures(DefaultLifecycleExe cutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeTaskSegments(DefaultLifecycleExecutor.jav a:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMav en.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven .java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:3 62)
at org.apache.maven.cli.compat.CompatibleMain.main(Co mpatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(L auncher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher. java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode (Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.ja va:375)
Caused by: org.apache.maven.plugin.PluginManagerException: Unable to load the mojo 'com.sun.enterprise:osgiversion-maven-plugin:0.4.11:compute-osgi-version' in the plugin 'com.sun.enterprise:osgiversion-maven-plugin'. A required class is missing: Lorg/apache/maven/shared/osgi/Maven2OsgiConverter;
at org.apache.maven.plugin.DefaultPluginManager.getCo nfiguredMojo(DefaultPluginManager.java:679)
at org.apache.maven.plugin.DefaultPluginManager.execu teMojo(DefaultPluginManager.java:468)
at org.apache.maven.lifecycle.DefaultLifecycleExecuto r.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/maven/shared/osgi/Maven2OsgiConverter;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.jav a:2291)
at java.lang.Class.getDeclaredField(Class.java:1880)
at hidden.org.codehaus.plexus.util.ReflectionUtils.ge tFieldByNameIncludingSuperclasses(ReflectionUtils. java:47)
at org.codehaus.plexus.component.composition.FieldCom ponentComposer.getFieldByName(FieldComponentCompos er.java:212)
at org.codehaus.plexus.component.composition.FieldCom ponentComposer.findMatchingField(FieldComponentCom poser.java:171)
at org.codehaus.plexus.component.composition.FieldCom ponentComposer.assembleComponent(FieldComponentCom poser.java:62)
at org.codehaus.plexus.component.composition.DefaultC omponentComposerManager.assembleComponent(DefaultC omponentComposerManager.java:68)
at org.codehaus.plexus.DefaultPlexusContainer.compose Component(DefaultPlexusContainer.java:1486)
at org.codehaus.plexus.personality.plexus.lifecycle.p hase.CompositionPhase.execute(CompositionPhase.jav a:29)
at org.codehaus.plexus.lifecycle.AbstractLifecycleHan dler.start(AbstractLifecycleHandler.java:101)
at org.codehaus.plexus.component.manager.AbstractComp onentManager.startComponentLifecycle(AbstractCompo nentManager.java:105)
at org.codehaus.plexus.component.manager.AbstractComp onentManager.createComponentInstance(AbstractCompo nentManager.java:95)
at org.codehaus.plexus.component.manager.PerLookupCom ponentManager.getComponent(PerLookupComponentManag er.java:48)
at org.codehaus.plexus.DefaultPlexusContainer.lookup( DefaultPlexusContainer.java:331)
at org.codehaus.plexus.DefaultPlexusContainer.lookup( DefaultPlexusContainer.java:440)
at org.apache.maven.plugin.DefaultPluginManager.getCo nfiguredMojo(DefaultPluginManager.java:652)
... 19 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.shared.osgi.Maven2OsgiConverter
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
at org.codehaus.classworlds.RealmClassLoader.loadClas sDirect(RealmClassLoader.java:195)
at org.codehaus.classworlds.DefaultClassRealm.loadCla ss(DefaultClassRealm.java:255)
at org.codehaus.classworlds.DefaultClassRealm.loadCla ss(DefaultClassRealm.java:274)
at org.codehaus.classworlds.RealmClassLoader.loadClas s(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)
... 36 more
[INFO] ----------------------------------------------------------------------
[INFO] Total time: 29 minutes 36 seconds
[INFO] Finished at: Fri Dec 21 13:07:49 IST 2012
[INFO] Final Memory: 13M/23M
[INFO] ----------------------------------------------------------------------
Complete log output of downloading process can be seen here - http://neelamsharma.s3.amazonaws.com/Maven_Result-2.2.1.txt
I am removing local repository ".m2" folder from my user each time before restart build. I have tried to download on different OS but it always stuck at same error.
Can anybody please let me know what settings are changed that I need to update ? Or which repositories need to remove to get rid of this error?Looks like there is some sun plugin being used there. Might be that you need the java.net nexus repository so maven can fetch plugin dependencies from it.
-
Javax.mail.MessagingException: 451 Error while writing spool file??
Hi all friends,
Can any one plz tell me why Iam getting below error when Iam trying to send mail with attachment.Iam using Java Mail API.
javax.mail.MessagingException: 451 Error while writing spool file
Plz tell me what are the reasons behind it.
Regards
BikashThe problem here is that the SMTP server was unable to write its spool file.
The error is probably on the OS side of things and has nothing to do with email except that the lack of the system resource is causing email to fail.
Have the server admin take a look at his error log to find out why the the user that smtp is running as could not write the file. -
[import javax.servlet.*;] Compilation error
Hi,
The java compiler cannot find javax.servlet.*; in Windows XP.
I tried copying servlet-api.jar under c:\sun\SDK\lib and c:\Sun\sdk\jdk\lib.
Also I set the CLASSPATH to:
.;C:\Sun\SDK\jdk\lib;C:\Sun\SDK\lib;
But I still get the error at compilation time.
Also I don't know how to create a project that would use the correct library and compile just that servlet code.
Many thanks for your help.Hi Xakep,
I have managed to compile the servlet, thanks to your help.
I have copied the servlet-api.jar under the directory C:\Sun\SDK\jdk\jre\lib
But in fact that was not enough if I chose to create a Java Project, because then the IDE is blind and can't see servlet-api.jar.
So I created a new project "Tomcat Project" and this time the .jar was visible, so I managed to build the servlet.class.
Also I wanted to compile from the command line so I used the classpath flag:
javac -classpath c:\sun\sdk\jdk\jre\lib\servlet-api.jar WelcomeServlet.javaMany thanks for your help -
Import from javax.mail cannot be resolved
Hi,
After migration from Netweaver 7.0 to 7.1 CE, the import of the package import javax.mail.*
The error is javax.mail cannot be resolved.
Do I have to add special Dependencies to my DC?
Best regards,
PeterHi
Please refer following thread.
[external jar in CE|import a external jar in web dynpro project;
[external library insight webdynpro |Problem in Reading Excel File from Webdynpro;
Best Regards
Satish Kumar -
Error using javax.mail package
Hi,
I have included the package javax.mail.* in my code.I have downloaded
jaf 1.0.2 and javamail 1.1.3 from the Sun Microsystems website.
When i try to compile my code i get the error message:
com/voxspectrum/ccvox/EmailServer.java:55: cannot resolve symbol
symbol : class MimeMessage
location: class com.voxspectrum.ccvox.EmailServer
javax.mail.Message msg = new MimeMessage(session);
I am using JDK ver 1.3.1_02. What should i set my path and classpath as, if i am using javax.mail package?
Please could you help me out with this problem!Hi Nisha
You need to include the path to the mail.jar and activation.jar files in your classpath.
How you do it depends on the OS you are running on
in Windows 95 /98 the easiest way is to edit the autoexec.bat file and add the settings to your already existing classpath statement i.e.
set CLASSPATH=%CLASSPATH%;C:\richard\javamail-1.3\mail.jar C:\richard\jaf-1.0.2\activation.jar
(excuse the word wrapping) then reboot
on Linux / Solaris edit the .profile file for your user and set the CLASSPATH variable to
CLASSPATH=$CLASSPATH:<pathtofile>/mail.jar:<pathtofile>/activation.jar
export CLASSPATH
and that should do it
Hope this helps -
Error: Javax.mail does not exist, please help
I have copies mail.jar and activation.jar in the classpath directory as instructed, then try to compile but got the below error: package javax.mail does not exist
please help.
G:\CRD>javac SendMailBean.java
SendMailBean.java:22: package javax.mail does not exist
import javax.mail.*; //JavaMail packages
^
SendMailBean.java:23: package javax.mail.internet does not exist
import javax.mail.internet.*; //JavaMail Internet packages
^
SendMailBean.java:43: cannot resolve symbol
symbol : class Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:43: cannot resolve symbol
symbol : variable Session
location: class SendMailBean
Session l_session = Session.getDefaultInstance(l_props, null);
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:48: cannot resolve symbol
symbol : class MimeMessage
location: class SendMailBean
MimeMessage l_msg = new MimeMessage(l_session); // Create a New message
^
SendMailBean.java:50: cannot resolve symbol
symbol : class InternetAddress
location: class SendMailBean
l_msg.setFrom(new InternetAddress(p_from)); // Set the From address
^
SendMailBean.java:53: package Message does not exist
l_msg.setRecipients(Message.RecipientType.TO,
^
SendMailBean.java:54: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_to, false));
^
SendMailBean.java:57: package Message does not exist
l_msg.setRecipients(Message.RecipientType.CC,
^
SendMailBean.java:58: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_cc, false));
^
SendMailBean.java:62: package Message does not exist
l_msg.setRecipients(Message.RecipientType.BCC,
^
SendMailBean.java:63: cannot resolve symbol
symbol : variable InternetAddress
location: class SendMailBean
InternetAddress.parse(p_bcc, false));
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:68: cannot resolve symbol
symbol : class MimeBodyPart
location: class SendMailBean
MimeBodyPart l_mbp = new MimeBodyPart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class Multipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:72: cannot resolve symbol
symbol : class MimeMultipart
location: class SendMailBean
Multipart l_mp = new MimeMultipart();
^
SendMailBean.java:83: cannot resolve symbol
symbol : variable Transport
location: class SendMailBean
Transport.send(l_msg);
^
SendMailBean.java:98: cannot resolve symbol
symbol : class MessagingException
location: class SendMailBean
} catch (MessagingException mex) { // Trap the MessagingException Error
^
19 errorsAnother person who doesn't understand how to set CLASSPATH.
Move those JARs into the same directory as your SendMailBean.java and do it like this:
javac -classpath .;mail.jar;activation.jar -d . *.java
java -classpath .;mail.jar;activation.jar SendMailBeanRead how to set CLASSPATH properly:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html -
Play Framework - Compilation error[object inject is not a member of package javax]
I would like to add to the table "Person" when you press the button "Add a Person" but I get an error:
play.PlayExceptions$CompilationException: Compilation error[object inject is not a member of package javax]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at play.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27) ~[na:na]
at scala.Option.map(Option.scala:145) ~[scala-library-2.11.1.jar:na]
controller is in the class Application:
package controllers
import play.api._
import play.api.mvc._
import play.api.data.Form
import play.api.data.Forms._
import play.api.libs.json.Json
import models._
import javax.inject._
class Application @Inject() (db: DB) extends Controller {
def index = Action {
Ok(views.html.index())
val personForm: Form[Person] = Form {
mapping(
"name" -> text
)(Person.apply)(Person.unapply)
def addPerson = Action { implicit request =>
val person = personForm.bindFromRequest.get
db.save(person)
Redirect(routes.Application.index)
I do not know how to add a library javax.inject-1.jar ?
Is there another solution . Thank for you help in this matter.If this is still an outstanding issue, and you have a valid CSI, a BDB support license, please access MOS (MyOracle Support) and review Note 1198943.1: "Building BDB XML 2.5.16 with STLPort on Solaris using Sun Studio". If you cannot access MOS, drop me an e-mail at andrei dot costache at the obvious domain, and I will send the details.
Regards,
Andrei -
Authorization error for referenced class javax/mail/Session.
All,
I am trying to compile a java source which is using session object in javax/mail/session.
I am getting the error java/lang/System: Authorization error for referenced class javax/mail/Session.
I used "import javax.mail.*;" in my java source..
I loaded both mail.jar and activation.jar using the below command in different schema other than the schema which above java source exists.
loadjava -thin -verbose -user <user>/<pwd>@<dburl> -resolve -synonym activation.jar
loadjava -thin -verbose -user <user>/<pwd>@<dburl> -resolve -synonym mail.jar
After loading, All java classes in mail.jar and activation.jar were in compiled state in that schema
Its working well in different database having the same configuration.
My oracle version is Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit ProductionI have to accomplish tried in CONSOLE TestMail.class:
C>java TestMail
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Partmy make.bat:
javac -g -classpath
...\Java\jre1.5.0_06\lib\activation.jar;...\jre1.5.0_06\lib\imap.jar;...\jre1.5.0_06\lib\mail.jar;...\jre1.5.0_06\lib\mailapi.jar;...\jre1.5.0_0\lib\plugin.jar;...\jre1.5.0_06\lib\pop3.jar;...\jre1.5.0_06\lib\smtp.jar;...\jre1.5.0_06\lib\javamail-1_3_2-src-jrl.zip;...\jre1.5.0_06\lib\j2ee.jar TestMail.javaWhat isn't correct?
Tanks,
Mohammad -
Netbeans can, jar can not - NoClassDefFoundError: javax/mail/Address
I have made a simple java application to send out emails. It works on Netbeans. That is, after compilation on Netbeans, and then run it on Netbeans, the email can be sent out successfully.
But after I made a jar file with cmd.exe, and then try to run it on cmd.exe, it throws the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Address
Can anyone help to illumine?
thanks a lot!I did, doesnt work. program only works if I run jar file from location where netbeans puts jar for distribution. If I copy the jar file from the dist to the directory I want to run the jar file, it cant find the other jar i want to include.
I have my program which compiles to a jar for distribution. In netbeans i point to a sqljdbc.jar for connecting to SQL Server. Running it from netbeans works fine. Copying the lib directory in the dist directory together with the jar to my destination where I want to run the program works fine too. But I would like to link to the sqljdbc.jar at its original location.
I have added C:\applibs\sqljdbc.jar to the path in Start >> My Computer >> Properties >> Advanced >> Environment Variables. Doesnt Work.
If I copy C:\dev\myapp\dist\myapp.jar to C:\apps\myapp.jar without copying C:\dev\myapp\lib to teh same location as well, it doesnt run. It gives the NoClassDefinationError when run at the command prompt
C:\apps>java -jar myapp.jar
I even tried
C:\apps>java -classpath .;C:\C:\applibs\sqljdbc.jar -jar myapp.jar
Its like the -classpath flag is being ignored. So obviously there is a concept I am misunderstanding. I read somewhere that I have to build my own jar file. Is that the only option? Should this theoretically be working? Can you just copy the jar file from the dist directory to run somewhere else provided the libs it uses is in the path at an OS level? -
Error while Loading Mail.jar in Database
Hi,
I am trying to load mail.jar in Oracle 8i Database(ver. 8.1.5.0.0). It is giving error insufficient previleges. Then I extracted mail.jar and tried to load class PasswordAuthentication of mail.jar in user scott. It gave me same error. But I could load the same class in user SYS.
Does it mean that, scott needs some special previleges for the classes in mail.jar. If so, How can I set those previleges ?
Thanking You.
Mrinal.
nullrdbms 8.1.5 had very tight restrictions on loading "system classes.
check the java doc for 8.1.5 on this.
check out the following
"protected packages" in the following
http://otn.oracle.com/doc/server.815/a64682/04jserve.htm#1001015
Protected Packages
You cannot replace system classes (those that CREATE JAVA SYSTEM installs, which you invoke with initjvm.sql at database initialization time). In addition, classes in any package (or sub-package) in which system classes reside, can be created only in the SYS schema. Protected packages include those starting with the patterns:
java
javax
oracle.aurora
oracle.jdbc
oracle.rdbms
oracle.sqlj
oracle.sqlnet
oracle.vm
oracle.weak
sun.tools
sun.misc
sun.net
com.visigenic.vbroker
com.sun.jndi
org.omg
sqlj
by the way 8.1.5 went out of support on dec 31, 2000. you need to consider moving to 8.1.7.
null -
Always get the InternetAddress & javax.mail.Session error
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<%@ page import="java.util.*,java.io.*" %>
<%@ page contentType="text/html;charset=big5" %>
<html>
<head>
<title>JavaMail</title>
</head>
<body>
<h2>利用JavaMail來傳送電子郵件 - 附加檔案</h2>
<%
InternetAddress[] address = null;
request.setCharacterEncoding("big5");
// MultipartRequest multi = new MultipartRequest(request , "." , 5*1024*1024 , "big5");
String mailserver = "mail.dwu.edu.tw";
String From = request.getParameter("From");
String to = request.getParameter("To");
String Subject = request.getParameter("Subject");
String type = request.getParameter("Type");
String messageText = request.getParameter("Message");
String FileName = request.getParameter("FileName");
boolean sessionDebug = false;
try {
// 設定所要用的Mail 伺服器和所使用的傳送協定
java.util.Properties props = System.getProperties();
props.put("mail.host",mailserver);
props.put("mail.transport.protocol","smtp");
// 產生新的Session 服務
javax.mail.Session mailSession = javax.mail.Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
// 設定傳送郵件的發信人
msg.setFrom(new InternetAddress(From));
// 設定傳送郵件至收信人的信箱
address = InternetAddress.parse(to,false);
msg.setRecipients(Message.RecipientType.TO, address);
// 設定信中的主題
msg.setSubject(Subject);
// 設定送信的時間
msg.setSentDate(new Date());
if (FileName != null)
File file = new File(FileName);
// 如果有附加檔案時,先將郵件內容部份先存起來
MimeBodyPart mbp1 = new MimeBodyPart();
// 設定郵件內容的型態為 text/plain 或 text/html
mbp1.setContent(messageText, type + ";charset=big5");
// 再來對檔案作處理
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(FileName);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(MimeUtility.encodeText(fds.getName(), "big5", "B"));
// 最後再將二者整合起來,當作一份郵件送出
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
else
// 若沒有檔案時,就直接存郵件內容
msg.setContent(messageText,type + ";charset=big5");
Transport.send(msg);
out.println("郵件己順利傳送");
catch (MessagingException mex)
mex.printStackTrace();
%>
</body>
</html>
==================================
i don't know why i always get the error about the type even i already add the jar file in lib folder:
InternetAddress cannot be resolved to a type
javax.mail.Session cannot be resolved to a typeWhat server are you using?
Did you follow the instructions on the JavaMail FAQ for setting up the server?
Did you restart the server? -
SHA1 digest error for javax/mail/Message.class
it's been 4 hrs that i am striving to get around this .....Does any body has any idea why this error appears and how to remedy it ....
help will be much much appreciated....Either:
1. Your mail.jar is corrupted, or
2. You have more than one copy of the javax.mail.Message class in your CLASSPATH. -
Error: SHA1 digest error for javax/mail/Authenticator.class
I am using javax.mail api to sending emails.
when I calls main method of the class to send email its works perfect, but when I imports the same class in jsp its shows me above said error.
My email server requires authentication before sending mails.
please guide me how to use this class in jsp .
class code is as below :
=========================
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
public class SendMailUsingAuthentication
private static final String SMTP_HOST_NAME = "myserver.smtphost.com";
private static final String SMTP_AUTH_USER = "myusername";
private static final String SMTP_AUTH_PWD = "mypwd";
private static final String emailMsgTxt = "Online Order Confirmation Message. Also include the Tracking Number.";
private static final String emailSubjectTxt = "Order Confirmation Subject";
private static final String emailFromAddress = "[email protected]";
// Add List of Email address to who email needs to be sent to
private static final String[] emailList = {"[email protected]", "[email protected]"};
public static void main(String args[]) throws Exception
SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
System.out.println("Sucessfully Sent mail to All Users");
public void postMail( 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", SMTP_HOST_NAME);
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
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);
msg.setRecipients(Message.RecipientType.TO, addressTo);
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
* SimpleAuthenticator is used to do simple authentication
* when the SMTP server requires it.
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
String username = SMTP_AUTH_USER;
String password = SMTP_AUTH_PWD;
return new PasswordAuthentication(username, password);Find all the jar files under Tomcat's installation directory and all the jar files in the jre/lib/ext directory.
Make sure only one of them includes javax.mail.* classes.
Note that setting CLASSPATH to a directory does not cause all jar files in that directory to be loaded.
Finally, make sure Eclipse isn't copying the class files out of mail.jar and packaging them with your
application. -
SHA1 digest error for javax/mail/MessagingException
java.lang.SecurityException: SHA1 digest error for javax/mail/MessagingException.class
at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:194)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:201)
at java.util.jar.JarVerifier.update(JarVerifier.java:188)
at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:411)
at sun.misc.Resource.getBytes(Resource.java:97)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:256)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
What could be the problem for this error Exception ???
Thanks and Regards.Hi!
Do you use some plugins with eclipse IDE, like Tomcat by example or other plugins ... ?
If yes, update mail.jar and activation.jar inside Tomcat or in your lib project Eclipse...
You have a conflict with the class loader that check for security for class javax/mail/MessagingException
See you Manifest.mf inside mail.jar :
(old version here...)
Manifest-Version: 1.0
Implementation-Version: 1.4
Specification-Title: JavaMail(TM) API Design Specification
Specification-Version: 1.3
Implementation-Title: javax.mail
Extension-Name: javax.mail
Created-By: 1.5.0 (Sun Microsystems Inc.)
Implementation-Vendor-Id: com.sun
Implementation-Vendor: Sun Microsystems, Inc.
Specification-Vendor: Sun Microsystems, Inc.
SCCS-ID: @(#)javamail.mf 1.6 05/12/09
Name: javax/mail/search/SearchTerm.class
SHA1-Digest: SwGnDhIUmpZhfhq/FKkCQ9nD7ZE=
Name: javax/mail/SendFailedException.class
SHA1-Digest: XdCEygaIZQB9YrH2WIr4nPRYYk0=
Name: javax/mail/MessagingException.class
SHA1-Digest: lfjX30OQ88v/n9G9fTJGqjFmPd0=
regards,
Maybe you are looking for
-
Loading External JAR librarys in an applet
HI all, I have an application that I would like to add an excell extention to. The extension is in the form of a JAR file, and I only want my applet to load this jar file when a menu item has ben clicked. I do not want the jar file to be loaded toget
-
I have cleared my cookies and cache and disabled some add ons, but when in Facebook and specifically for Farmville, I keep getting the pop up box, "This web page is being redirected to a new location. Would you like to resend the form data you have t
-
Oracle repository in application server
how to create the oracle repository in application server.
-
Spry Image Slideshow with Filmstrip not showing online
I just put up an image slideshow. It works locally, but online the spinning wheel spins all the time. The viewport does not show any image. The filmstrip does show the thumbnails, and the navigation works. My guess is that the images I used for the v
-
Problem viewing Tutorials on Adobe TV. Do not see controls. Help!
Just installed PS Elements 11 from CD. Went to view tutorials. List of tutorials opened, selected a tutorial from list, blank black view screen appeared. No controls appeared for viewing. No start, stop, volume, no controls. Have I missed somethi