Server time went out of sync

Last Sunday night I received a call from one of my clients that the pdf generation stopped working! What on earth! It was working fine for the 2 years and it decided this Sunday to stop working? What happened? I checked the code (nothing was committed accidentally). Checked the requests “Server can not generate pdf”. Then after a bit of debugging it turned out that the code that was uploading the generated PDF to Amazon S3 was throwing an error. Luckily the error description was quite clear:

The difference between the request time and the current time is too large.

So right away I checked the hour of the server that generates the PDF files & indeed it was around 15 mins in front. After a bit of looking up online I found that you can sync your server time using the command below. And that right away solved the issue & PDF generation was magically fixed 🙂


sudo ntpdate ntp.ubuntu.com
sudo apt install ntp
sudo systemctl reload ntp.service

You can read more about it on Ubuntu documentation

Problem with java and SSL Exception

For the last 2 weeks we had a problem with email sending on one of our servers (hosted on EC2). Our emails are sent through Amazon SES, which used to work great until a problem with SSL connections on Amazon SES came up. Since that time we started receiving complaints that some clients didn’t receive email confirmations. We investigated the issue (checked our error logs) and it seemed that we had to wait until Amazon fixes the issue (at least that’s what we thought). Amazon fixed the issue very quickly but we continued having problems. Today we found the solution by noticing that on one of the servers emails were being sent without any problem. And we noticed that on that server we had installed openjdk-6 instead of openjdk-7 as on the other server. Therefore we switched to openjdk-6 and it all started working normally!

Therefore, if you get an error similar to the one blow then we would recommend that you switch to openjdk-6 instead of openjdk-7.

Note: We tried configuring a completely new server (thinking that a SSL certificate needed to be updated) but didn’t help. Switching to openjdk-6 did the job 🙂

Here is the error:

play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[MessagingException: Exception reading response]]
	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:134) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:115) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at akka.actor.Actor$class.apply(Actor.scala:318) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at play.core.ActionInvoker.apply(Invoker.scala:113) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at akka.actor.ActorCell.invoke(ActorCell.scala:626) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.dispatch.Mailbox.run(Mailbox.scala:179) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
	at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) ~[com.typesafe.akka.akka-actor-akka-actor-2.0.2.jar:2.0.2]
Caused by: javax.mail.MessagingException: Exception reading response
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1462) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1260) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at javax.mail.Service.connect(Service.java:297) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at javax.mail.Service.connect(Service.java:156) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at javax.mail.Service.connect(Service.java:105) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at fly.play.ses.Ses$.sendEmail(Ses.scala:49) ~[nl.rhinofly.api-ses_2.9.1-api-ses_2.9.1-1.0.1.jar:1.0.1]
	at facade.Emails$.sendActivationEmail(Emails.scala:15) ~[easygogym_2.9.1-0.1.jar:0.1]
	at controllers.Users$$anonfun$sendActivationEmail$1.apply(Users.scala:116) ~[easygogym_2.9.1-0.1.jar:0.1]
	at controllers.Users$$anonfun$sendActivationEmail$1.apply(Users.scala:114) ~[easygogym_2.9.1-0.1.jar:0.1]
	at play.api.mvc.Action$$anon$1.apply(Action.scala:170) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply(Invoker.scala:126) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at play.utils.Threads$.withContextClassLoader(Threads.scala:17) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:125) ~[play.play_2.9.1-play_2.9.1-2.0.6.jar:2.0.6]
	... 11 common frames omitted
Caused by: javax.net.ssl.SSLException: Server key
	at sun.security.ssl.Handshaker.throwSSLException(Handshaker.java:1274) ~[na:1.7.0_25]
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223) ~[na:1.7.0_25]
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868) ~[na:1.7.0_25]
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:804) ~[na:1.7.0_25]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016) ~[na:1.7.0_25]
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) ~[na:1.7.0_25]
	at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:882) ~[na:1.7.0_25]
	at sun.security.ssl.AppInputStream.read(AppInputStream.java:102) ~[na:1.7.0_25]
	at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) ~[na:1.7.0_25]
	at java.io.BufferedInputStream.read(BufferedInputStream.java:254) ~[na:1.7.0_25]
	at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75) ~[javax.mail.mail-mail-1.4.jar:1.4]
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440) ~[javax.mail.mail-mail-1.4.jar:1.4]
	... 25 common frames omitted
Caused by: java.security.spec.InvalidKeySpecException: Could not create EC public key
	at sun.security.pkcs11.P11ECKeyFactory.engineGeneratePublic(P11ECKeyFactory.java:169) ~[sunpkcs11.jar:1.7.0_25]
	at java.security.KeyFactory.generatePublic(KeyFactory.java:334) ~[na:1.7.0_25]
	at sun.security.ssl.HandshakeMessage$ECDH_ServerKeyExchange.(HandshakeMessage.java:1057) ~[na:1.7.0_25]
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:218) ~[na:1.7.0_25]
	... 36 common frames omitted
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DOMAIN_PARAMS_INVALID
	at sun.security.pkcs11.wrapper.PKCS11.C_CreateObject(Native Method) ~[sunpkcs11.jar:1.7.0_25]
	at sun.security.pkcs11.P11ECKeyFactory.generatePublic(P11ECKeyFactory.java:233) ~[sunpkcs11.jar:1.7.0_25]
	at sun.security.pkcs11.P11ECKeyFactory.engineGeneratePublic(P11ECKeyFactory.java:164) ~[sunpkcs11.jar:1.7.0_25]
	... 39 common frames omitted