2

I am getting this error when trying to send emails via gmail smtp inside servlet it works locally when tested but not inside google engine i added the libs under web-inf/libs [activation.jar-smtp.jar- mailapi.jar - mail.jar] any idea how i can fix it!!

Error: javax.servlet.ServletContext log: unavailable java.lang.SecurityException: SHA1 digest error for javax/mail/Message.class at com.google.appengine.run

Code Snapshot:

 Properties props = new Properties();
 props.setProperty("mail.transport.protocol", "smtp");
 props.setProperty("mail.host", "smtp.gmail.com");
 props.put("mail.smtp.auth", "true"); 
 props.put("mail.smtp.port", "465"); 
 //props.put("mail.debug", "true");
 props.put("mail.smtp.socketFactory.port", "465");
 props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
 props.put("mail.smtp.socketFactory.fallback", "false");
 javax.mail.Session sess = javax.mail.Session.getInstance(props);
 Transport transport = sess.getTransport(); 
 transport.connect();
 transport.send(message);
Hardik Mishra
  • 14,479
  • 9
  • 59
  • 96
  • From the excpetion trace it looks like your code is deployed on appengine. If i remember correctly app engine does not allow you to send email. Please recheck the documentation – Anupam Saini Oct 17 '12 at 07:33

2 Answers2

1

You cannot use signed jar files on Google app engine.

As indicated on the web page, you should try to unsign it, specifically the mail.jar because the error is indicating javax/mail/Message.class, see this question for an example

Community
  • 1
  • 1
Alex
  • 24,385
  • 6
  • 56
  • 53
0

App Engine's precompilation isn't compatible with signed JAR files. If your application is precompiled (the default), it can't load signed JAR files. If the application tries to load a signed JAR, at runtime App Engine will generate an exception like yours.
No Signed JAR Files

There is two way to work around.

  1. Strip the JAR's signature
  2. Disabling Precompilation
Sumit Singh
  • 24,095
  • 8
  • 74
  • 100
  • Done what you suggested from mail.jar removed the signatures from MANIFEST-MF Signature-Version: 1.0 SHA1-Digest-Manifest: removed SUN_MICR.SF However, i no longer get the previous error but a new one as per below I 2012-10-17 12:44:13.080 ERROR.....com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'remote_socket – user1752300 Oct 17 '12 at 08:52
  • take a look of this https://groups.google.com/forum/?fromgroups=#!topic/google-appengine/2pSRB8ADDd8 – Sumit Singh Oct 17 '12 at 08:55
  • https://groups.google.com/forum/?fromgroups=#!topic/google-appengine-java/H3v7qIM25ls http://stackoverflow.com/questions/12710865/the-api-package-remote-socket-or-call-resolve-was-not-found-gae-java – Sumit Singh Oct 17 '12 at 08:57
  • i did check the group not that useful, however, it pointed me to google [https://developers.google.com/appengine/docs/java/mail/overview] that stated When creating a JavaMail Session, you do not need to provide any SMTP server configuration. App Engine will always use the Mail service for sending messages. meaning no properties required but still get the error 2012-10-17 13:12:45.766 [s~forextraderstore/1.362512707070217485].: ERROR.....javax.mail.NoSuchProviderException: Invalid protocol: null – user1752300 Oct 17 '12 at 09:15
  • When creating a JavaMail Session, App Engine doesn't require SMTP properties, not true as per the below error ERROR.....javax.mail.NoSuchProviderException: Invalid protocol: null – user1752300 Oct 17 '12 at 09:19