javax.mail.MessagingException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

If you're using wiremock, configure your code to accept wiremock self-signed certificate or create a keystore and certificate that are trusted by your HTTP client and configure wiremock to use that


rafael
tip

Set the 'mail.smtp.ssl.trust' system property to an smtp host, like 'smtp.gmail.com'.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Issue of SMTP in mailing code ON TEST SERVER
    via Stack Overflow by abhi314
    ,
  • email code not working on test environment
    via Stack Overflow by abhi314
    ,
  • Send mail using Java Mail API
    via Stack Overflow by Avi
    ,
  • Jenkins configured to automatically download and install Java from standard download source. 17:10:07 Installing JDK jdk-8u102-oth-JPR 17:10:07 Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-windows-x64.exe 17:10:07 ERROR: SEVERE ERROR occurs 17:10:07 org.jenkinsci.lib.envinject.EnvInjectException: 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 17:10:07 at org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables(EnvInjectVariableGetter.java:91) 17:10:07 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:233) 17:10:07 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:46) 17:10:07 at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:572) 17:10:07 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:492) 17:10:07 at hudson.model.Run.execute(Run.java:1720) 17:10:07 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) 17:10:07 at hudson.model.ResourceController.execute(ResourceController.java:98) 17:10:07 at hudson.model.Executor.run(Executor.java:404) 17:10:07 Caused by: 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 17:10:07 at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) 17:10:07 at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) 17:10:07 at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) 17:10:07 at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) 17:10:07 at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) 17:10:07 at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) 17:10:07 at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) 17:10:07 at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) 17:10:07 at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) 17:10:07 at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) 17:10:07 at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747) 17:10:07 at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123) 17:10:07 at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) 17:10:07 at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) 17:10:07 at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828) 17:10:07 at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116) 17:10:07 at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) 17:10:07 at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) 17:10:07 at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) 17:10:07 at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) 17:10:07 at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) 17:10:07 at hudson.tools.JDKInstaller.locate(JDKInstaller.java:470) 17:10:07 at hudson.tools.JDKInstaller.performInstallation(JDKInstaller.java:137) 17:10:07 at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:68) 17:10:07 at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:109) 17:10:07 at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:206) 17:10:07 at hudson.model.JDK.forNode(JDK.java:144) 17:10:07 at org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables(EnvInjectVariableGetter.java:86) 17:10:07 ... 8 more 17:10:07 Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 17:10:07 at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387) 17:10:07 at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) 17:10:07 at sun.security.validator.Validator.validate(Validator.java:260) 17:10:07 at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) 17:10:07 at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) 17:10:07 at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) 17:10:07 at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) 17:10:07 ... 31 more 17:10:07 Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 17:10:07 at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) 17:10:07 at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) 17:10:07 at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) 17:10:07 at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) 17:10:07 ... 37 more
    via by Jesper Jensen,
    • javax.mail.MessagingException: Can't send command to SMTP host; 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 at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420) at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408) at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384) at javax.mail.Service.connect(Service.java:297) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at javax.mail.Transport.send0(Transport.java:168) at javax.mail.Transport.send(Transport.java:98) at org.apache.jsp.testEmail_jsp.sendMail(testEmail_jsp.java:90) at org.apache.jsp.testEmail_jsp._jspService(testEmail_jsp.java:173) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: 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 at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979) at sun.security.ssl.Handshaker.process_record(Handshaker.java:914) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747) at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123) at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:101) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1418) ... 36 more Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387) at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292) at sun.security.validator.Validator.validate(Validator.java:260) at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324) at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229) at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491) ... 47 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126) at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280) at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382) ... 53 more

    Users with the same issue

    Unknown visitor1 times, last one,
    rocday
    1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    poroszd
    1 times, last one,
    55 more bugmates