关闭

javamail的一些小bug

170人阅读 评论(0) 收藏 举报
分类:

在写用java开发邮箱发送的过程中遇到了某些问题,其实这些问题很简单,但是但是弄啦我一天。

  真心累,都是公司的网络不给力,什么网络都限制害得我弄啦一天


在做的过程中有下面的一些bug.希望对后学者有帮助

java.lang.ClassNotFoundException: javax.mail.Authenticator
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
    at com.zsb.action.ActivateMailAction.registerPwd(ActivateMailAction.java:73)
    at com.zsb.action.ActivateMailAction.doPost(ActivateMailAction.java:53)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


那是因为没有mail.jar包


org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.163.com:25
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)
    at org.apache.commons.mail.Email.send(Email.java:1267)
    at com.zsb.util.SendEmailUtil.getSendEmail(SendEmailUtil.java:37)
    at com.zsb.action.ActivateMailAction.registerPwd(ActivateMailAction.java:73)
    at com.zsb.action.ActivateMailAction.doPost(ActivateMailAction.java:53)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.mail.NoSuchProviderException: smtp
    at javax.mail.Session.getService(Session.java:764)
    at javax.mail.Session.getTransport(Session.java:689)
    at javax.mail.Session.getTransport(Session.java:632)
    at javax.mail.Session.getTransport(Session.java:612)
    at javax.mail.Session.getTransport(Session.java:667)
    at javax.mail.Transport.send0(Transport.java:148)
    at javax.mail.Transport.send(Transport.java:80)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)
    ... 25 more



这个错误好像是因为oracle已经发布了1.7.4的mail.jar包了。不用像以前那样添加两个jar包(activation.jar、javamail.jar)其实现在不用他们两个 了。只用一个mail.jar就可以了。还有要保证公司的网络不能对这些邮箱端口

进行限制,否则不能保证哦!

现在只要两个或者一个jar包就可以了(mail.jar  / commons-email.jar)

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:11744次
    • 积分:227
    • 等级:
    • 排名:千里之外
    • 原创:7篇
    • 转载:17篇
    • 译文:1篇
    • 评论:1条
    文章分类