0

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.

EviL GaMer
  • 133
  • 13

2 Answers2

0

You're probably running into this JDK bug, which is fixed in newer versions of the JDK. What version of the JDK is your server using?

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • The version running on the server is at least 1.8 and it seems that the bug has been resolved by then. It also seems to happen when loading attachments with SOAP. I only use SOAP to start the code and the rest is done by the server. Nevertheless I did try the workaround and it sadly didn't help. – EviL GaMer Jan 11 '18 at 08:17
  • Actually, that bug is probably not the cause of the problem. What does the [JavaMail debug output](https://javaee.github.io/javamail/FAQ#debug) show? NoSuchProviderException is sometimes the result of class loader bugs that make the server unable to find the configuration file included in the javax.mail.jar file. Also, make sure the server doesn't include an older version of JavaMail that is conflicting with the version included in your application. If the server has an older version, you might be able to just depend on that. – Bill Shannon Jan 11 '18 at 19:01
0

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

EviL GaMer
  • 133
  • 13