views:

479

answers:

1

I'm relatively new to Groovy and Grails and am trying them out in my spare time. I've got a small test Grails application that I'm able to run fine using grails run-app, but grails run-war results in an error.

In the grails-app/conf/BootStrip.init method, I'm adding some property getters onto the DefaultGrailsControllerClass and DefaultGrailsApplication:

DefaultGrailsControllerClass.metaClass.getMenuText = { ->
    getPropertyOrStaticPropertyOrFieldValue('menuText', String.class)
}
DefaultGrailsControllerClass.metaClass.getMenuOrder = { ->
    getPropertyOrStaticPropertyOrFieldValue('menuOrder', Integer.class)
}
DefaultGrailsApplication.metaClass.getMenuControllerClasses = { ->
    controllerClasses.findAll { it.menuText != null }.sort { it.menuOrder }
}

In my grails-app/views/layouts/main.gsp, I'm using this:

<g:each var="c" in="${ grailsApplication.menuControllerClasses }">
    <li><g:link controller="${c.logicalPropertyName}">${c.menuText}</g:link></li>
</g:each>

This works fine under run-app, but running it under run-war, I get the following:

groovy.lang.MissingPropertyException: No such property: menuControllerClasses for class: org.codehaus.groovy.grails.commons.DefaultGrailsApplication

I've tried this under Grails 1.1.1 and 1.2-M1 and get the same result. I've verified that the BootStrap.init method is being called (via a println), but the changes made to the metaClass don't appear to take under run-war.

Any idea what I'm missing?

A: 

grails run-war -- Run's a Grails application's WAR in Jetty

grails run-app -- Runs a Grails application in Jetty

The difference seems to be that run-war does not support reloading as run-app does.

Not sure what you are missing.

Sean A.O. Harney