3 Replies Latest reply on Feb 23, 2017 8:18 AM by ehugonnet

    javax.mail.NoSuchProviderException smtp

    Steve Warsa Newbie

      Hello,

       

      I'm trying to port over a working app from WebSphere to JBoss EAP 7.  Most things are working now, but I just discovered that email (which is working in WebSphere) is not working with same code, configuration and jars in JBoss.  I get:

       

      09:05:02,815 INFO  [stdout] (default task-66) Caused by: javax.mail.NoSuchProviderException: smtp

      09:05:02,815 INFO  [stdout] (default task-66) at javax.mail.Session.getService(Session.java:794)

      09:05:02,815 INFO  [stdout] (default task-66) at javax.mail.Session.getTransport(Session.java:716)

      09:05:02,815 INFO  [stdout] (default task-66) at javax.mail.Session.getTransport(Session.java:656)

      09:05:02,816 INFO  [stdout] (default task-66) at javax.mail.Session.getTransport(Session.java:636)

      09:05:02,816 INFO  [stdout] (default task-66) at org.springframework.mail.javamail.JavaMailSenderImpl.getTransport(JavaMailSenderImpl.java:521)

      09:05:02,816 INFO  [stdout] (default task-66) at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:500)

      09:05:02,816 INFO  [stdout] (default task-66) at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:421)

       

      I have inspected the session object in the debugger and see the following providers:

       

      javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc],

      javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc],

      javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc],

      javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc],

      javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc],

      javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]

       

      I have a jar in my EAR called mail.jar which inside it has a manifest.mf file which reports version 1.4, but I noticed that there is also a jar in JBoss called javax.mail-1.5.5.redhat-1.jar.  I wondered if maybe there was a conflict between my jar and the one provided by JBoss, so I put an exclusion statement for that module in my jboss-deployment-structure.xml:

       

      <exclusions>

        <module name="javax.mail.api" />

      </exclusions>

       

      Then I get javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_1207807808.1487780234754".

       

      I found some more detailed logging regarding the above exception on the server log:

       

      2017-02-22 09:42:26,767 FINE  [javax.activation] (default task-45) MailcapCommandMap: load HOME

      2017-02-22 09:42:26,772 FINE  [javax.activation] (default task-45) new MailcapFile: file C:\Users\xxxxxxx\.mailcap

      2017-02-22 09:42:26,773 FINE  [javax.activation] (default task-45) MailcapCommandMap: load SYS

      2017-02-22 09:42:26,773 FINE  [javax.activation] (default task-45) new MailcapFile: file C:\Java\jdk1.8.0_112\jre\lib\mailcap

      2017-02-22 09:42:26,773 FINE  [javax.activation] (default task-45) MailcapCommandMap: load JAR

      2017-02-22 09:42:26,774 FINE  [javax.activation] (default task-45) MailcapCommandMap: !anyLoaded

      2017-02-22 09:42:26,774 FINE  [javax.activation] (default task-45) MailcapCommandMap: not loading mailcap file: /META-INF/mailcap

      2017-02-22 09:42:26,774 FINE  [javax.activation] (default task-45) MailcapCommandMap: load DEF

      2017-02-22 09:42:26,774 FINE  [javax.activation] (default task-45) new MailcapFile: InputStream

      2017-02-22 09:42:26,776 FINE  [javax.activation] (default task-45) parse: image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45)   Type: image/gif

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45)     Command: view, Class: com.sun.activation.viewers.ImageViewer

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45) parse: image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45)   Type: image/jpeg

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45)     Command: view, Class: com.sun.activation.viewers.ImageViewer

      2017-02-22 09:42:26,777 FINE  [javax.activation] (default task-45) parse: text/*;; x-java-view=com.sun.activation.viewers.TextViewer

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)   Type: text/*

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)     Command: view, Class: com.sun.activation.viewers.TextViewer

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45) parse: text/*;; x-java-edit=com.sun.activation.viewers.TextEditor

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)   Type: text/*

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)     Command: edit, Class: com.sun.activation.viewers.TextEditor

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45) Merging commands for type text/*

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45) MailcapCommandMap: successfully loaded mailcap file: /META-INF/mailcap.default

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45) MailcapCommandMap: createDataContentHandler for text/html

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)   search DB #1

      2017-02-22 09:42:26,778 FINE  [javax.activation] (default task-45)   search fallback DB #1

      2017-02-22 09:42:26,850 FINE  [javax.activation] (default task-45) MailcapCommandMap: createDataContentHandler for multipart/mixed

      2017-02-22 09:42:26,851 FINE  [javax.activation] (default task-45)   search DB #1

      2017-02-22 09:42:26,851 FINE  [javax.activation] (default task-45)   search fallback DB #1

       

      I see a lot of information about how to set up email in JBoss, but I was hoping I could just port over the working system with as minimal changes as possible.

       

      Any suggestions?

       

      Thanks,

      Steve

        • 1. Re: javax.mail.NoSuchProviderException smtp
          Steve Warsa Newbie

          Update - I removed the mail.jar from my EAR and manifest, so that the code would rely on the JBoss provided jar.  Then I got this (note the error in bold at the bottom):

           

          2017-02-22 09:49:01,636 CONFIG [javax.mail] (default task-48) JavaMail version 1.5.5

          2017-02-22 09:49:01,640 CONFIG [javax.mail] (default task-48) successfully loaded resource: /META-INF/javamail.default.providers

          2017-02-22 09:49:01,641 CONFIG [javax.mail] (default task-48) Tables of loaded providers

          2017-02-22 09:49:01,641 CONFIG [javax.mail] (default task-48) Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}

          2017-02-22 09:49:01,641 CONFIG [javax.mail] (default task-48) Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}

          2017-02-22 09:49:01,642 CONFIG [javax.mail] (default task-48) successfully loaded resource: /META-INF/javamail.default.address.map

          2017-02-22 09:49:01,667 ERROR [stderr] (default task-48) java.lang.LinkageError: loader constraint violation: when resolving method "javax.mail.internet.MimeBodyPart.setDataHandler(Ljavax/activation/DataHandler;)V" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/springframework/mail/javamail/MimeMessageHelper, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for the method's defining class, javax/mail/internet/MimeBodyPart, have different Class objects for the type javax/activation/DataHandler used in the signature

          • 2. Re: javax.mail.NoSuchProviderException smtp
            Steve Warsa Newbie

            Update - based on suggestion here, I removed activation.jar from classpath and the problem went away... However, I don't know why I needed that in the first place, so it remains to be seen if this will have other negative effects.  But for now, problem solved.

             

            FYI,

            Steve

            • 3. Re: javax.mail.NoSuchProviderException smtp
              ehugonnet Apprentice

              That's because the activation.jar is already provided by WildFly thus you have the same class in 2 different jars loaded through different classloaders.