javasoapjakarta-mailibm-odmnosuchproviderexception

Getting a NoSuchProviderException when using Javamail with SOAP


I have written a software that basically logs into a mail account and searches the inbox folder for unread emails and looks whether the subject is the one specified and then takes it's attachment(s) and does something with them. This software is then deployed onto an IBM Rule Execution Server and launched via SOAP.

For that cause I am using Javamail 1.6. The following snippet works fine locally:

Session session = Session.getInstance(mailProperties);

    try (Store store = session.getStore(mailProperties
        .getProperty("mail.store.protocol"))) {

        store.connect(mailProperties.getProperty("mail.imap.host"),
                mailProperties.getProperty("mail.user"),
                mailProperties.getProperty("mail.password"));

With the mailProperties having been initialised beforehand correctly and so on and so on. Having deployed the full code SOAPUI delivers the following NoSuchProviderException:

Caused by: javax.mail.NoSuchProviderException: imaps
    at javax.mail.Session.getService(Session.java:842)
    at javax.mail.Session.getStore(Session.java:626)
    at javax.mail.Session.getStore(Session.java:602)

I tried to include the provider as

Provider provider = new Provider(...);
store.connect(provider);

Though that resulted in the same exception.

After that I tried to avoid the provider fully by initializing the store as an IMAPSSLStore but that threw a java.lang.LinkageError at me. Trying to resolve this in different ways (including setting the ClassLoader to a different one) didn't help.

I am honestly a bit at a loss of wits now on how to proceed with this.

It seems to me that there is trouble finding the providers which should be included in the javax.mail.jar.


Solution

  • I have found the answer to my question myself. The Liberty server included by IBM has a featureManager in the server.xml. There you need to input:

    <feature>javaMail-1.5</feature>

    to make it work -.-