Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-5058

IMAPProvider class not found when sending email from Script Console in Jira 8.10.0+

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Cannot Reproduce
    • Affects Version/s: 6.15.0, 6.19.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Critical Points:
      0

      Description

      Sending a custom email from Script Console resulting in the following error:

      java.util.ServiceConfigurationError: javax.mail.Provider: Provider com.sun.mail.imap.IMAPProvider not found 

      However, this only happens on Jira 8.10.0+.

      Steps to Reproduce

      1. Install Jira 8.10.0+ and the latest version of ScriptRunner
      2. Send an email using this script on Script Console
      3. Hits "IMAPProvider class not found" error

      Workaround

      Manually add the class to the current thread with the code below as per this community post:

      // Rest of the imports
      import com.atlassian.mail.server.SMTPMailServer;
      
      // Rest of the codes
      ClassLoader threadClassLoader = Thread.currentThread().getContextClassLoader()
      Thread.currentThread().setContextClassLoader(SMTPMailServer.class.classLoader)
      mailServer.send(email)
      Thread.currentThread().setContextClassLoader(threadClassLoader)

      After running the script above and successfully sent an email, using back the old script seems to be working fine up until Jira is restarted.

      Basically, the steps are:

      1. Send an email for the first time - Error
      2. Add the thread code - Worked
      3. Removed the thread code - Worked
      4. Restart Jira - Error again
      5. Then back to step 2

      Additional Info

      • Jira 8.9.1 - Working fine.
      • Jira 8.10.0 & 8.13.2 - Error.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            hibrahim Helmy Ibrahim
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: