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