Thursday, May 31, 2012

Fix for PortletGrailsPlugin for Grails 2.x


 Problem:


Using the Grails Portlet plugin version 0.9.1 within a Grails 2.0.0 environment I get the following error:

Caused by MissingMethodException: No signature of method: org.codehaus.groovy.grails.plugins.web.ControllersGrailsPlugin.registerControllerMethods()

 Solution:

 We get this problem because in the lastet version of Grails 2.x, the "registerControllerMethods()" method no longer exists, and nobody is currently maintaining the plugin at the moment. But I've been working hard to find a solution so here it is.


In the PortletsGrailsPlugin.groovy file change the following from:


         def controllersPlugin = new ControllersGrailsPlugin()
         controllersPlugin.registerControllerMethods(mc, ctx)


To this:
         def enhancer = new MetaClassEnhancer()
         enhancer.addApi(new ControllersApi(getManager()))
         enhancer.enhance mc

No comments:

Post a Comment