问题描述
我尝试执行下面提到的蚂蚁邮件任务,我收到错误消息:java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
.
I tried to execute below mentioned ant mail task, I'm getting error message: java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
.
我已经为 ant 创建了环境变量.
I have created environment variable for ant.
还放了mail.jar、激活jar &lib
文件夹中的 ant-javamail jar 以及 eclipse ->偏好 ->全局条目
.执行蚂蚁邮件任务还需要什么?请提出建议.
Also placed mail.jar, activation jar & ant-javamail jar in lib
folder as well as in eclipse -> preferences -> Global Entries
. Anything else required for executing ant mail task? Please suggest.
<target description="Generates and send TestNG test reports" name="send-report">
<mail mailhost="smtp.sears.com" mailport="25" user="kmart\vlakshm" password="AK230211$$" ssl="true" subject="Test build">
<from address="[email protected]"></from>
<replyto address="[email protected]"></replyto>
<to address="[email protected]"></to>
<message>Please find the attached report for Sears International smoke test results.</message>
<attachments>
<fileset dir="C:\\Documents and Settings\\vlakshm\\workspace\\INTL_REG\\test-output\\emailable-report.html">
<include name="**/*.zip"/>
</fileset>
</attachments>
</mail>
</target>
在命令提示符下,执行下面提到的命令
In command prompt,executed below mentioned command
ant send-report
获得下面提到的例外
build.xml:70: java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.tools.ant.taskdefs.email.EmailTask.execute(EmailTask.java:
452)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
推荐答案
在 ANT_HOME/lib 中添加 mail.jar 和 activation.jar 或在您的项目/lib 中同时使用这两个 jar
add mail.jar and activation.jar in ANT_HOME/lib or use both jar form your project/lib
这篇关于获取错误消息“java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage"在执行蚂蚁邮件任务时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!