I have the following bean to inject to all the controllers
beans = {
db(my.DatabaseRepo) { singleton true }
}
when I define
class MyController {
def db
index() {
}
}
I got the following error
java.lang.ClassCastException: my.DatabaseRepo cannot be cast to groovy.lang.Closure
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
This is http://jira.grails.org/browse/GRAILS-7800 and is fixed, so this won’t be a problem in M2. As a temporary workaround you can import the class of the bean and explicitly type it instead of using ‘def’: