Javamail 1.5.1,Tomcat 7和java.lang.ClassNotFoundException:javax.mail.Authenticator [英] Javamail 1.5.1, Tomcat 7, and java.lang.ClassNotFoundException: javax.mail.Authenticator

查看:155
本文介绍了Javamail 1.5.1,Tomcat 7和java.lang.ClassNotFoundException:javax.mail.Authenticator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Javamail 1.5.1与Tomcat 7和Eclipse Kepler结合使用.

I trying to use Javamail 1.5.1 with Tomcat 7 and Eclipse Kepler.

当我尝试发送电子邮件时,Tomcat崩溃并显示以下错误...

When I try to send an email, Tomcat blows up with the error below...

从文档中,我了解到我现在所需要的一切都在javax.mail.jar中.而且我将其保存在webapp的WEB-INF/lib文件夹中.

From the docs, I understand that everything I need is now within the javax.mail.jar. And I have that in the webapp's WEB-INF/lib folder.

我认为这是在抱怨找不到javax.mail.Authenticator.但是我已经确认该类在jar中.

I think it's complaining that it can't find javax.mail.Authenticator. But I have confirmed that the class is within the jar.

这应该很容易.有人可以指出我想念的东西吗?

This should be easy. Could someone please point out what I am missing?

我还将该jar添加到了Eclipse偏好设置中作为库.

I have also added the jar to eclipse preferences as a Library.

也...在哪里可以下载到javadoc,也可以将其添加到eclipse中?即,所以我可以将鼠标悬停在单词上并获取文档?

Also... where to I get the downloaded javadoc so I can add that to eclipse too? i.e. so I can hover the mouse over a word and get the docs?

谢谢

java.lang.NoClassDefFoundError: javax/mail/Authenticator
org.apache.naming.factory.MailSessionFactory.getObjectInstance(MailSessionFactory.java:106)
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
org.apache.naming.NamingContext.lookup(NamingContext.java:843)
org.apache.naming.NamingContext.lookup(NamingContext.java:154)
org.apache.naming.NamingContext.lookup(NamingContext.java:831)
org.apache.naming.NamingContext.lookup(NamingContext.java:168)
util.SendEmails.<init>(SendEmails.java:47)
...

推荐答案

我遇到了完全相同的问题,我通过将Java Mail jar添加到tomcat lib目录中来解决此问题.

I had exactly the same issue, and I fixed this by adding the Java Mail jar to the tomcat lib directory.

我认为错误的原因是,在JNDI查找期间,不会加载webapp本身的类,因此,要使JNDI正常工作,您需要将jar直接提供给tomcat,而不是在您的webapp.

I'm thinking the cause of the error is that during the JNDI lookup the classes from the webapp itself are not loaded, so in order for the JNDI to work you need to provide the jar directly to tomcat, instead of in your webapp.

这篇关于Javamail 1.5.1,Tomcat 7和java.lang.ClassNotFoundException:javax.mail.Authenticator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆