javax.mail.MessagingException: Exception reading response; nested exception is:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target

- 5,891
- 4
- 36
- 55

- 11
- 1
-
2We can't help you without seeing the code that causes the Exception. – Dragondraikk May 12 '15 at 08:59
-
The first Google result for `SunCertPathBuilderException: unable to find valid certification path to requested target` has your answer. Please do some more research into Tomcat and its HTTPS configuration. – RustyTheBoyRobot May 12 '15 at 16:36
-
possible duplicate of [Error in JavaMail : PKIX path building failed unable to find valid certification path to requested target](http://stackoverflow.com/questions/20122099/error-in-javamail-pkix-path-building-failed-unable-to-find-valid-certification) – RustyTheBoyRobot May 12 '15 at 16:37
-
The remote server isn't trusted by your local server. Verify the remote server's certificate, and then make arrangements for your server to trust the remote one. – Christopher Schultz May 24 '15 at 16:15
1 Answers
javax.mail.MessagingException can occur due to many reasons. Since you have not posted any code , it is virtually impossible to say correctly what caused this.
looking at second part of error "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
Now again i cannot say with 100% certainty but most probable these kind of error are related to certificate . ie most probably Your Java runtime doesn’t trust the certificate.
Normally Java verifies certificates through the standard chain of trust mechanism. But if that chain terminates with a certificate that Java doesn’t trust, then Java will complain in the way described above.
The solution if this is the case would be to
1. Download the certificate from the remote SMTP server
2. Import the certificate into your local truststore
Detailed information for these are available at below link
http://springinpractice.com/2012/04/29/fixing-pkix-path-building-issues-when-using-javamail-and-smtp
Also check the following links
how to ignore server cert error in javamail
How to solve an error: unable to find valid certification path to requested target error in Java?