Andrew
Andrew

Reputation: 376

GNU JavaMail: No provider for address: rfc822

Using OpenJDK 1.7.0 and GNU JavaMail 1.1.2.

During the actual message send call:

SMTPTransport.send(msg);

This happens:

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) produces the same result.

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"/>

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

Upvotes: 1

Views: 2731

Answers (2)

Laurent Gr&#233;goire
Laurent Gr&#233;goire

Reputation: 4146

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>

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).

Original reference of the solution here.

Upvotes: 2

James
James

Reputation: 359

It looks like your program is trying to set rfc822 as the domain address to be used for the transport layer. Is this a valid address? I suggest searching your code for this reference as the problem is undoubtedly around that area.

Upvotes: 0

Related Questions