10

I am new to working with jakarta.mail. I am getting the following error when creation the Session object for jakarta.mail.

java.lang.IllegalStateException: Not provider of jakarta.mail.util.StreamProvider was found

The error is thrown by the FactoryFinder class find method when called by the StreamProvider class provider method, seems there are no available service providers?? Not sure what this means, new to writing email notification code.

authenticator is null, port is 25.

alfonx
  • 6,936
  • 2
  • 49
  • 58
Percival Bragg
  • 101
  • 1
  • 3
  • This answer helped me and solved the problem: [error while sending mail using javamail](https://stackoverflow.com/a/29209401) – tomboss May 16 '23 at 10:14

3 Answers3

19

It appears that you are only linking to the jakarta.mail-api library, which only contains the API and not the actual implementation. Try something like this in your Maven POM file.

Note the inclusion of the org.eclipse.angus:jakarta.mail dependency.

        <!-- Jakarta email support -->
        <!-- https://jakarta.ee/specifications/mail/ -->
        <!-- https://github.com/jakartaee/mail-api -->
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://github.com/eclipse-ee4j/angus-mail -->
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>jakarta.mail</artifactId>
            <version>1.0.0</version>
        </dependency>
Rob Stoecklein
  • 749
  • 6
  • 9
2

It helped me. Replace your jakarta dependencies to this

<dependency>
    <groupId>com.sun.mail</groupId>
    <artifactId>jakarta.mail</artifactId>
    <version>2.0.1</version>
</dependency>
Ivan B
  • 31
  • 2
-2

Just a quick hint on this. Make sure you are running the jakarta.mail related methods in a thread safe environment

Ole K
  • 754
  • 1
  • 9
  • 32