Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grails error: return type of getGrailsApplication() is incompatible

we are upgrading a grails 2.2.5 application to grails 3.1 and have an interesting error. What does this mean and how should it be resolved?

/myapp/grails-app/controllers/myapp/admin/AdminProjectController.groovy: -1: 
The return type of java.lang.Object getGrailsApplication() in myapp.admin.AdminProjectController is incompatible with grails.core.GrailsApplication in grails.web.api.WebAttributes
. At [-1:-1]  @ line -1, column -1.
like image 539
Jay Prall Avatar asked Aug 23 '16 17:08

Jay Prall


1 Answers

Thanks to burtbeckwith on this issue.

"Controllers in Grails 2 and Grails 3 already have an implicit dependency injection for GrailsApplication, so you're adding a second. In Grails 2 it's not typed (def grailsApplication) but in Grails 3 it is typed (GrailsApplication grailsApplication), so you've effectively added an override, but with a less specific return type which is invalid. Just delete your def grailsApplication and use the one that's already there."

If you just remove def grailsApplication from all controllers it will be fixed.

like image 52
Jay Prall Avatar answered Nov 07 '22 06:11

Jay Prall