You have setup a new machine in my case you just paid for a brand new dedicated server and you install your wonderful application bam you get hit by a CertificateNotYetValidException.
2013-06-28 22:34:16,499 [http-8080-15] ERROR errors.GrailsExceptionResolver - CertificateNotYetValidException occurred when processing request: [POST] /user/save
NotBefore: Fri Jul 12 03:56:36 CDT 2013. Stacktrace follows:
java.security.cert.CertificateNotYetValidException: NotBefore: Fri Jul 12 03:56:36 CDT 2013
at java.security.cert.CertPathValidator.validate(CertPathValidator.java:267)
at com.megatome.grails.recaptcha.net.Post.getText(Post.groovy:38)
at com.megatome.grails.recaptcha.ReCaptcha.checkAnswer(ReCaptcha.groovy:121)
at com.megatome.grails.RecaptchaService.verifyAnswer(RecaptchaService.groovy:112)
at com.intelquotations.security.UserController.save(UserController.groovy:33)
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.lang.Thread.run(Thread.java:679)
For a while there I could not figure out it was a very simple matter of the system clock being far behind and I was looking all over and not enough help from the internet then finally by dumb luck I decided to run command "date" and the date on the machine was way behind. My fix was just correct the date and Bob is your uncle.
Hope this saves someone out there some time.
Why cant everything be easier
Monday, July 29, 2013
Sending Email Asynchronously in Grails
Sending Email Asynchronously in Grails
You are working on a project and during one of the transactions there has to be a lot of emails sent but you dont want to keep the user's response waiting for all those emails to send then you want to do it asynchronously. In my grails application I am using the mail plugin (version 1.0.1) and for asynchronous activities I am using plugin executor plugin (version 0.3). The combination of the two plugins allowed me to send all my mails in the background without the user waiting. Here is how:To setup the mail plugin:
http://grails.org/plugin/mail
To setup executor service:
http://grails.org/plugin/executor
1. In your resources.groovy add this bean
executorService( grails.plugin.executor.PersistenceContextExecutorWrapper ) { bean->
bean.destroyMethod = 'destroy'
persistenceInterceptor = ref("persistenceInterceptor")
executor = Executors.newCachedThreadPool()
}
You can override and use your own custom thread pool but for this task lets go basic.
2. In any controller where you want to use the executor service you can inject it
def
3. For simplicity like I did use the shortcut methods runAsync which takes any closure
4. In runAsync put your sendMail calls to send email
runAsync {
sendMail {
....
}
}
It worked for me so well hope you are able to find it useful too.
Grails and a big Project by a hardened java developer
Hardened java developer's journey into grails
I recently undertook a major project building a new product called intelquotations. This started as a small project with very little funds and so I decided to use grails instead of the normal Java servlets or Spring. intelquotations is now live here at www.intelquotations.com. I developed the first version of the product in as little as 3 weeks thanks to the incredible power and agility of grails and the wealth of plugins that can be leveraged. To the developers of grails thank you and the many contributors of plugins my love you are life savers.I will do a blog where I detailed my journey to intelquotations later.
Subscribe to:
Comments (Atom)