3
我在eclipse和tomcat服务器上使用maven。使用maven和tomcat的javamail 6
我必须制作一个小程序,如果需要每小时使用java邮件发送一封电子邮件。
我在webapp中修改了我的web.xml。
我像这样在POM.xml中添加了邮件。
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>
因为我不需要激活,因为使用jdk 1.6。
我还修改了的context.xml
然后复制的mail.jar到Tomcat/lib文件夹。
但我越来越奇怪的错误。
java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at fr.project.batch.jobs.SendEmail.execute(SendEmail.java:53)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
2014-04-07 10:01:47,539 ERROR duler_Worker-1 Job (DEFAULT.SendMail threw an exception. [ErrorLogger]
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session]
at org.quartz.core.JobRunShell.run(JobRunShell.java:227)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
Caused by: java.lang.ClassCastException: javax.mail.Session cannot be cast to javax.mail.Session
at fr.project.batch.jobs.SendEmail.execute(SendEmail.java:53)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
... 1 more
我已经在tomcat 6.0 JavaMail资源中阅读了很多次,并且经历了很多stackoverflow的答案。
非常感谢您的回答。但我的问题是Eclipse。因为我是通过日食发射,所以我有一个恐怖。但是当我在tomcat服务器中使用war文件时,它就起作用了。 @ KristjanVeskimäe我正在使用eclipse在tomcat 6.0中进行测试。我很感谢你对这个问题的回应。 – Akash