java 1.7 找不到 javaxmail,Javamail 1.5.1,Tomcat 7和java.lang.ClassNotFoundException:javax.mail.Authentic...

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

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

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.

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?

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

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?

Thanks

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.(SendEmails.java:47)

...

解决方案

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

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值