Sunday, October 10, 2010

Weird Grails Scaffold Exception

Using the dynamic scaffolding feature (in Grails V1.3.4) like
package de.scheelethek.backoffice.crud
class CommentController {
    def scaffold = true
}
I've got a runtime exception like
2010-10-10 13:11:44,417 [http-8080-1] ERROR errors.GrailsExceptionResolver  - java.lang.Boolean cannot be cast to groovy.lang.Closure
java.lang.ClassCastException: java.lang.Boolean cannot be cast to groovy.lang.Closure
 at java.lang.Thread.run(Thread.java:619)

It looks like Grails is trying to interpret the scaffold-definition as an action.
The explanation was not far to seek:

The referenced domain class is defined in the package "de.scheelethek.backoffice". The controller uses another package definition. scaffold=true is searching just in the same package for a corresponding domain definition. If not found "def scaffold", it is interpreted as an action.

The solution is obvious. Do an explicit definition of the domain class that should be used:
package de.scheelethek.backoffice.crud
import de.scheelethek.content.*
class CommentController {
    def scaffold = Comment
}

No comments:

Post a Comment

And Feedback? Please post a comment: