Since Grails v1.1.1 has come out, there has been a strange issue. It seems to sneak up on me every time something important happens, like a production release. Grails throws an exception and I see an error page on my web browser. The exception always looks something like this:
2009-07-16 21:10:16,923 ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver:60 groovy.lang.MissingPropertyException: No such property: save for class: foo.Bar
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingPropertyException: No such property: save for class: foo.Bar
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:92)
...
Caused by: groovy.lang.MissingPropertyException: No such property: save for class: foo.Bar
at foo.BarController$_closure8.doCall(BarController.groovy:105)
at foo.BarController$_closure8.doCall(BarController.groovy)
Research has revealed that other people face this issue as well. Some solutions that people have proposed:
- Wait a few minutes and try again
- Restart your application server (this seems to work well for me)
- run
MyDomainClass.countin your Bootstrap.groovy - run
MyDomainClass.get(-1)before you attempt save
These all seem like black magic to me, though. I wanted to actually understand what was going on. I found the related JIRA (GRAILS-4580) and even the commit that Graeme made to fix it (which will be available in grails 1.2).
After everything I’ve read it seems like it’s another problem with Hibernate proxy objects not getting initialized correctly. This, however, does not explain why it’s been fixed with an application server restart for me each time, or if there’s anything I can do to avoid it while I’m still using Grails v1.1.1.
My plan going forward: Do not change my approach. When I see this issue in the future I’ll continue to attempt black magic. If I have a show stopper issue, I’ll apply the fix to grails v1.1.1.