GNU JavaMail:没有地址提供者:rfc822 [英] GNU JavaMail: No provider for address: 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屋!