javax.mail.NoSuchProviderException:没有smtps的提供者 [英] javax.mail.NoSuchProviderException: No provider for smtps

查看:2847
本文介绍了javax.mail.NoSuchProviderException:没有smtps的提供者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置我的Java项目以便能够发送电子邮件(通过g-mail,如果它很重要)并且我每次尝试都会收到javax.mail.NoSuchProviderException:没有smtps的提供者运行以下行(从他们的示例中复制/粘贴)。

I'm trying to set up my Java project to be able to send e-mail (via g-mail, if it matters) and am getting "javax.mail.NoSuchProviderException: No provider for smtps" every time I try to run the following line (which is copy/paste from their example).

Transport transport = session.getTransport("smtps");

我环顾四周,发现这通常被抛出,因为你没有邮件。 jar包含在你的类路径中,但我确实包含了mail.jar。由于我运行的是JDK 1.6,因此我不需要在FAQ中包含activation.jar( http://www.oracle.com/technetwork/java/javamail/faq-135477.html#classpath )。此外,在javamail的1.4.7版本中似乎不存在activation.jar。

I've looked around and found that this is generally thrown because you don't have the mail.jar included in your classpath, but I do in fact have the mail.jar included. Since I am running JDK 1.6 I do not need to include the activation.jar according to the FAQ here (http://www.oracle.com/technetwork/java/javamail/faq-135477.html#classpath). Further, the activation.jar does not seem to be present in version 1.4.7 of javamail.

为了防止出现问题,我重新下载了整个zip文件oracle的网站,提取它并添加jar新鲜(删除旧jar后),我仍然得到相同的错误。关于此问题可能出现的任何想法?

Just in case something got corrupted, I re-downloaded the entire zip from oracle's website, extracted it and added the jar fresh (after deleting the old jar) and I am still getting the same error. Any thoughts as to what the issue could be at this point?

编辑:这是正在打印的完整堆栈跟踪:

Here is the full stack trace that is being printed:

javax.mail.NoSuchProviderException: No provider for smtps
    at javax.mail.Session.getProvider(Session.java:433)
    at javax.mail.Session.getTransport(Session.java:627)
    at javax.mail.Session.getTransport(Session.java:608)
... my code that calls getTransport() ...
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
... more of my code ...
    at java.lang.Thread.run(Thread.java:662)


推荐答案

事实证明问题是mail.jar的过时版本是包含的ded在我引用的项目中,在更新mail.jar的副本后,问题得到解决。

So it turns out that the issue was that an outdated version of mail.jar was included in a project that I was referencing and, upon updating that copy of the mail.jar, the issue was resolved.

为了将来参考,有没有办法记录或提供此类jar冲突的可见性?

For future reference, is there any way to log or provide visibility on such jar conflicts?

https://confluence.atlassian.com/confkb/cannot-send-email-due-to-javax-mail-nosuchproviderexception-smtp- error-154079.html

这篇关于javax.mail.NoSuchProviderException:没有smtps的提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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