0

我试图执行下面提到的 ant 邮件任务,我收到错误消息:java.lang.ClassNotFoundException: javax.mail.internet.MimeMessage

我已经为 ant 创建了环境变量。

还将 mail.jar、激活 jar 和 ant-javamail jar 放在lib文件夹中以及eclipse -> preferences -> Global Entries. 执行蚂蚁邮件任务还需要什么?请建议。

<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="vijayalakshmi.lakshmanan@searshc.com"></from>
     <replyto address="vijayalakshmi.lakshmanan@searshc.com"></replyto>
     <to address="vijayalakshmi.lakshmanan@searshc.com"></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>

在命令提示符下,执行下面提到的命令

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
4

1 回答 1

3

在 ANT_HOME/lib 中添加 mail.jar 和 activation.jar 或使用项目/lib 中的两个 jar

于 2013-09-26T07:55:07.027 回答