-
Notifications
You must be signed in to change notification settings - Fork 0
javax.mail.NoSuchProviderException: Provider class does not have a constructor(Session, URLName)
Exception:
javax.mail.NoSuchProviderException: Provider class does not have a constructor(Session, URLName)
SOLUTION: javax.mail/1.6.2.jar file is not included in the WebApp.war file which is deployed in the server. If not available then after creating the war build. In war file, lib folder download javax.mail.jar and add it
Different Ways of solution:
-
stackpost Removing the duplicate
javax.mailclasses from the webapp fixes the problem. - POST: I read some threads in several forums where people had encountered the same when there were multiple versions of java mail available through different classloaders.
Fail LOG:
DEBUG: getProvider() returning provider protocol=imap; type=javax.mail.Provider$Type@6accb714; class=com.sun.mail.imap.IMAPStore; vendor=Oracle
javax.mail.NoSuchProviderException: Provider class does not have a constructor(Session, URLName): protocol=imap; type=javax.mail.Provider$Type@6accb714; class=com.sun.mail.imap.IMAPStore; vendor=Oracle
at javax.mail.Session.getService(Session.java:488)
at javax.mail.Session.getStore(Session.java:296)
at javax.mail.Session.getStore(Session.java:271)
at com.java.mail.IMAP_MimeMail.mailFetch(IMAP_MimeMail.java:317) // session.getStore("imap");
Success LOG:
DEBUG: JavaMail version 1.6.2
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: setDebug: JavaMail version 1.6.2
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
DEBUG IMAP: mail.imap.partialfetch: false
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
pom.xml
<!-- Java Mail -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.58</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcmail-jdk15on</artifactId>
<version>1.58</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.58</version>
</dependency>
<!-- javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId><!-- bcprov-jdk16[1.46] -->
<version>1.58</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.8</version>
</dependency>
<!-- import org.apache.poi.hsmf.MAPIMessage; import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; -->
<dependency>
<groupId>ch.astorm</groupId>
<artifactId>jotlmsg</artifactId>
<version>1.7</version>
<exclusions>
<exclusion> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId> </exclusion>
<exclusion> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> </exclusion>
</exclusions>
</dependency>
<!-- NoClassDefFoundError: com/sun/mail/util/MailLogger -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
<exclusions>
<exclusion> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> </exclusion>
</exclusions>
</dependency>Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files UnlimitedJCEPolicyJDK8C:\Softwares\JDK\jdk1.8.0_121\jre\lib\security
we need to extract the zipped file into a directory of our choice – which contains two jar files: local_policy.jar, US_export_policy.jar
Finally, we need to look for the {JAVA_HOME}/lib/security folder and replace the existing policy files with the ones that we’ve extracted here.
Java KeyStores (
*.jks, *.keystore, *.jceks, *.ks) PKCS #12 Keystores (*.pfx, *.p12) Bouncy Castle Keystores (*.bks, *.uber)
Baeldung.com Preparing Certificate And Private Key Baeldung.cer, Baeldung.p12 (password = “password”)
Symmetric Key encryption: The private keys and corresponding certificates are stored in files ending with ".p12". These are PKCS12 files with password
passwd.
KeyStore Explorer
github KeyStore Explorer is an open-source GUI replacement for the Java command-line utilities keytool and jarsigner.