Not provider of jakarta.mail.util.StreamProvider was found

3,768 views
Skip to first unread message

Florin Spătar

unread,
Jun 22, 2023, 7:17:29 AM6/22/23
to WildFly
Hi,

I'm using WildFly 28.0.1, and I'm trying to use the jakarta.mail.api.
I added these module dependencies to my module:

        <module name="javax.mail.api" export="true"/>
        <module name="org.eclipse.angus.mail" export="true"/>

but sending mail fails with:

java.lang.IllegalStateException: Not provider of jakarta.mail.util.StreamProvider was found
        at jakarta.mail.api//jakarta.mail.util.FactoryFinder.find(FactoryFinder.java:64)
        at jakarta.mail.api//jakarta.mail.util.StreamProvider.provider(StreamProvider.java:186)
        at jakarta.mail.api//jakarta.mail.Session.<init>(Session.java:254)
        at jakarta.mail.api//jakarta.mail.Session.getDefaultInstance(Session.java:381)
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotificationEmail.send(WlmJobNotificationEmail.java:203)                                                                            
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotificationEmail.notify(WlmJobNotificationEmail.java:85)                                                                          
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotification.notifyOnFailure(WlmJobNotification.java:72)                                                                            
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotification.notifyOnAny(WlmJobNotification.java:32)                                                                                
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.JobQueueManager.startAndUpdateJobRuntime(JobQueueManager.java:622)                                                                        
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.JobQueueManager$JobDistributionThread.run(JobQueueManager.java:867)

Looked over jakarta.mail.util.FactoryFinder.find method, and was able to fix this by adding the following system property: -Djakarta.mail.util.StreamProvider=org.eclipse.angus.mail.util.MailStreamProvider

But I was under the impression that adding org.eclipse.angus.mail module dependency should be enough to load services from angus.jar/META-INF/services/

Am I doing something wrong or this is the way it's supposed to work?

Thanks.

Alexey Makhmutov

unread,
Jun 22, 2023, 10:01:27 AM6/22/23
to WildFly
Hi,

Try to add dependency as:
        <module name="org.eclipse.angus.mail" export="true" services="export"/>

Thanks,
Alexey

Florin Spătar

unread,
Jun 22, 2023, 10:08:44 AM6/22/23
to WildFly
Hi,

Tried both, this:
        <module name="javax.mail.api" export="true" services="import"/>
        <module name="org.eclipse.angus.mail" export="true" services="import"/>
and this:
        <module name="javax.mail.api" export="true"/>
        <module name="org.eclipse.angus.mail" export="true" services="export"/>
but I still get the same error

Thanks,
Florin

Scott Marlow

unread,
Jun 22, 2023, 10:45:46 AM6/22/23
to Florin Spătar, WildFly


On 6/22/23 7:17 AM, Florin Spătar wrote:
Hi,

I'm using WildFly 28.0.1, and I'm trying to use the jakarta.mail.api.
I added these module dependencies to my module:

        <module name="javax.mail.api" export="true"/>
        <module name="org.eclipse.angus.mail" export="true"/>

What happens if you add neither of these module dependencies but instead just try to use the jakarta.mail api?

Scott


but sending mail fails with:

java.lang.IllegalStateException: Not provider of jakarta.mail.util.StreamProvider was found
        at jakarta.mail.api//jakarta.mail.util.FactoryFinder.find(FactoryFinder.java:64)
        at jakarta.mail.api//jakarta.mail.util.StreamProvider.provider(StreamProvider.java:186)
        at jakarta.mail.api//jakarta.mail.Session.<init>(Session.java:254)
        at jakarta.mail.api//jakarta.mail.Session.getDefaultInstance(Session.java:381)
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotificationEmail.send(WlmJobNotificationEmail.java:203)                                                                            
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotificationEmail.notify(WlmJobNotificationEmail.java:85)                                                                          
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotification.notifyOnFailure(WlmJobNotification.java:72)                                                                            
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.WlmJobNotification.notifyOnAny(WlmJobNotification.java:32)                                                                                
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.JobQueueManager.startAndUpdateJobRuntime(JobQueueManager.java:622)                                                                        
        at deployment.main.ear.shared-session.jar//com.opsware.shared.job.JobQueueManager$JobDistributionThread.run(JobQueueManager.java:867)

Looked over jakarta.mail.util.FactoryFinder.find method, and was able to fix this by adding the following system property: -Djakarta.mail.util.StreamProvider=org.eclipse.angus.mail.util.MailStreamProvider

But I was under the impression that adding org.eclipse.angus.mail module dependency should be enough to load services from angus.jar/META-INF/services/

Am I doing something wrong or this is the way it's supposed to work?

Thanks.
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/cb72aa12-9a6c-4474-8181-3af2567e8dafn%40googlegroups.com.

Florin Spătar

unread,
Jun 22, 2023, 11:27:50 AM6/22/23
to WildFly
Using <module name="jakarta.mail.api" export="true"/> instead of the two modules mentioned above, has the exact same behavior. javax.mail.api is just a module alias for jakarta.mail.api

Thanks,
Florin

Scott Marlow

unread,
Jun 22, 2023, 11:44:50 AM6/22/23
to Florin Spătar, WildFly


On 6/22/23 11:27 AM, Florin Spătar wrote:
Using <module name="jakarta.mail.api" export="true"/> instead of the two modules mentioned above, has the exact same behavior. javax.mail.api is just a module alias for jakarta.mail.api

Is your module application deployment?  Or are you manually adding your module under wildfly/modules?

If you are deploying an application that you wish to use jakarta.mail from, that should be handled via https://github.com/wildfly/wildfly/blob/main/mail/src/main/java/org/jboss/as/mail/extension/MailDependenciesProcessor.java which adds dependencies for jakarta.mail.api + jakarta.activation.api + org.eclipse.angus.mail + org.eclipse.angus.activation via constructor in https://github.com/wildfly/wildfly-core/blob/main/server/src/main/java/org/jboss/as/server/deployment/module/ModuleDependency.java. 

The source references can help you see the settings used by MailDependenciesProcessor.java that you likely need to use also.

Scott

Florin Spătar

unread,
Jun 26, 2023, 2:27:22 AM6/26/23
to WildFly

For a better understanding, here is my environment:


```

┌────────────────┐ ┌─────────────────────────────────┐ ┌─────────────────────────┐

│ │ depends on │ │depends on│ │

│ main.ear ├───────────────► mymodule-from-wildfly/modules ├──────────► jakarta.mail.api │

│ │ │ │ │ │

└────────────────┘ └─────────────────────────────────┘ └─────────────────────────┘

```


So,my module that depends on jakarta.mail.api is manually added under wildfly/modules, and I try to use the jakarta.mail.api from main.ear

I replicated what MailDependenciesProcessor.java does, and added the following dependencies to my module:


<module name="jakarta.mail.api" export="true" services="import"/>

<module name="jakarta.activation.api" export="true" services="import"/>

<module name="org.eclipse.angus.mail" export="true" services="import">

<imports>

<include path="META-INF"/>

</imports>

</module>

<module name="org.eclipse.angus.activation" export="true" services="import"/>


Tried to add these dependencies directly to main.ear as well, but I cannot seem to get rid of the issue. The only thing that works for me is using -Djakarta.mail.util.StreamProvider=org.eclipse.angus.mail.util.MailStreamProvider system property as initially described.


Thank you all for the help.


Yeray Borges Santana

unread,
Jun 26, 2023, 11:45:21 AM6/26/23
to Florin Spătar, WildFly
Hello Florin,

I suspect you are hitting this issue: https://github.com/jakartaee/mail-api/issues/665
We also faced this issue in the Wildfly Mail Subsystem, Jakarta mail requires the Angus mail services available at the Thread Context Class Loader.

Probably in your use case, the TCCL is not your module, so even importing the Angus Mail services to your module, you are still hitting it.
I'm not sure what's the TCCL in your example, can you provide a full error stack to see if we can get any conclusion for there? 

The #665 PR describes in more detail the root cause. It would be great if you can provide a reproducer so we can take a closer look.

Reply all
Reply to author
Forward
0 new messages