Just wanted to post quickly about a workaround to a Grails bug I dropped into to my application lately. There seems to some strange problem with Grails not binding the GORM methods to the domain objects intermittently.
Eg horrible errors like this
groovy.lang.MissingPropertyException: No such property: save for class: XXXXX
I only seem to get this problem in production on a Tomcat 6.0 server. I super quick fix that seemed to solve it at the time was to restart the tomcat server after a deployment. But that was too shaky for me.
Unfortunately is happening on a really important piece of my application. When i take payment. So i end up taking payment via my provider Paypal but not saving the transaction details in my own database.
Anyway after some searching around it seems like the problem it might have been fixed in the upcoming Grails 1.1.2
But for now this seems to do the trick. Someone posted this quick fix on the forums. The problem is with the hibernate only lazily adding the GORM method and some problem with groovy not recognising them.
So the trick is to get Hibernate plugin to register them at start up. So in your bootstrap.groovy add the following:
class BootStrap {
def grailsApplication
def init = {servletContext ->
switch (grails.util.GrailsUtil.environment) {
case "production":
grailsApplication.domainClasses.each{
def clazz = it.clazz
println "Clazz: $clazz count: " + clazz.count();
}
break;
case "development":
// dev stuff
break;
}
}
}
This simply calls count on all domain objects and prints out the count. You don't have to print out the count it was just nice for me.
Hope this helps