GNU JavaMail:没有地址提供者:rfc822 [英] GNU JavaMail: No provider for address: rfc822

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

问题描述

使用 OpenJDK 1.7.0 和 GNU JavaMail 1.1.2.

Using OpenJDK 1.7.0 and GNU JavaMail 1.1.2.

在实际的消息发送调用期间:

During the actual message send call:

SMTPTransport.send(msg);

发生这种情况:

javax.mail.NoSuchProviderException: No provider for address: rfc822
    at javax.mail.Session.getTransport(Session.java:641)
    at javax.mail.Transport.doSend(Transport.java:149)
    at javax.mail.Transport.send(Transport.java:75)

Transport.send(msg) 产生相同的结果.

Transport.send(msg) produces the same result.

我很确定我的类路径没问题.以下是它在 JAR 任务中的 build.xml 中的定义方式:

I'm pretty sure my classpath is OK. Here's how it's defined in build.xml in the JAR task:

<zipfileset src="${sys}/inetlib.jar" includes="**/*.java **/*.class"/>
<zipfileset src="${sys}/gnumail-providers.jar" includes="**/*.java **/*.class"/>
<zipfileset src="${sys}/gnumail.jar" includes="**/*.java **/*.class"/>

${sys} 是/usr/share/java.我是不是不得不放弃并使用 Oracle JavaMail API?

Where ${sys} is /usr/share/java. Am I going to have to suck it up and use the Oracle JavaMail API?

推荐答案

我遇到了和你一样的问题,它碰巧是由 jar geronimo-javamail_1.4_spec 搞砸了.一个简单的解决方案是将其从您的依赖项中排除.使用 Maven,假设它是 CXF 的依赖项:

I got the same problem as you and it happened to be caused by the jar geronimo-javamail_1.4_spec messing things up. A simple solution is to exclude it from your dependencies. With Maven, assuming it's a dependency from CXF:

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-rt-core</artifactId>
  <version>2.7.5</version>
  <exclusions>
    <exclusion>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-javamail_1.4_spec</artifactId>
  </exclusion>
  </exclusions>
</dependency>

至于确切原因,我没有花时间进一步调查.这肯定是一个多线程安全错误(当多个线程同时使用 SMTP 时我得到了它).

As to know exactly why, I did not took the time to investigate further. It's a multi-thread safety bug for sure (I got it when multiple threads where speaking SMTP at the same time).

解决方案的原始参考这里.

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

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