I have a tomcat web application with jre6. It runs in https mode. It sends mail alerts. The application has self generated certificate as a truststore file generated using Keytool - JRE 6.
Recently upgraded the application with jre7. And I shall change the application to https mode which generates truststore file using Keytool -JRE7. Here I couldn't send mail. Throws below error. There is no change between both application code. Just the jre is difference.
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 com.server.util.MailServerHandler.checkMailServer(MailServerHandler.java:145)|
Java Mail Debug goes here. It stops at EHLO command.
DEBUG: !anyLoaded|
DEBUG: not loading resource: /META-INF/javamail.providers|
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers|
DEBUG: Tables of loaded providers|
DEBUG: not loading resource: /META-INF/javamail.address.map|
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]|
DEBUG SMTP: useEhlo true, useAuth true|
DEBUG SMTP: useEhlo true, useAuth true|
DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 587, isSSL false|
250-smtp.gmail.com at your service
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
DEBUG SMTP: Found extension "SIZE", arg "35882577"|
DEBUG SMTP: Found extension "8BITMIME", arg ""|
DEBUG SMTP: Found extension "STARTTLS", arg ""|
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""|
DEBUG SMTP: Found extension "PIPELINING", arg ""|
DEBUG SMTP: Found extension "CHUNKING", arg ""|
DEBUG SMTP: Found extension "SMTPUTF8", arg ""|
STARTTLS
220 2.0.0 Ready to start TLS
EHLO rajesh-2668
Here is the smtp property I set.
mail.smtp.starttls.enable=true
mail.debug=true
mail.smtp.port=587
mail.smtp.auth=true
mail.smtp.host=smtp.gmail.com
mail.smtp.starttls.required=true
mail.smtp.timeout=10000
mail.smtp.connectiontimeout=10000
I Can't figure out what goes wrong? Do I require need any code level change or any conf changes? Please throw some lights over here as I'm stuck over a week on this. Helps are highly appreciated.