简体   繁体   中英

Grails 2.4 won't read config file from /opt

Please note: Although I'm using the Grails Shiro plugin I believe this to be a core Grails problem, having nothing to do with the plugin whatsoever.


Mac (Yosemtie) and Grails 2.4.5 here. Here's the top 2 lines from my Config.groovy :

String configFileAbsPath = System.getProperty('configFileAbsPath')
grails.config.locations = [ "file:${configFileAbsPath}" ]

So to run locally I do something like:

grails -DconfigFileAbsPath=/Users/myuser/tmp/myapp.properties run-app

When I run this exact invocation, my app starts up and behaves just fine.

However, in non-local environments I want my config file to live under /opt/myapp/myapp.properties . So on my local machine I create a /opt/myapp directory, and then ran chmod -R 777 /opt/myapp . I then copy myapp.properties to it and run:

grails -DconfigFileAbsPath=/opt/myapp/myapp.properties run-app

This produces the following stack trace:

| Error Error generating web.xml file (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingPropertyException: No such property: shiro for class: java.lang.String
    at ShiroGrailsPlugin$_closure4_closure30_closure34.doCall(ShiroGrailsPlugin.groovy:248)
    at ShiroGrailsPlugin$_closure4_closure30_closure34.doCall(ShiroGrailsPlugin.groovy)
    at ShiroGrailsPlugin$_closure4_closure30.doCall(ShiroGrailsPlugin.groovy:243)
    at ShiroGrailsPlugin$_closure4_closure30.doCall(ShiroGrailsPlugin.groovy)
    at ShiroGrailsPlugin$_closure4.doCall(ShiroGrailsPlugin.groovy:242)

I seriously doubt that the location of an external config file, or the file permissions set on the config file (or its parent dir) would break the Grails Shiro plugin. I think this is just a misleading Grails/Groovy exception. Most likely some kind of security exception is causing something to not load/populate correctly (and fail silently), and then when Grails Shiro kicks in during run-app , its missing something that should be there and is causing run-app to die.

Any ideas as to what is going on, or what the fix is?


Update : Running grails clean , grails clean-all and/or grails refresh-dependencies prior to invoking grails run-app do not help/solve this error either.

我通常更喜欢使用.groovy文件作为外部配置,而不是.properties,因为我可以将printlns写入其中,以检查文件是否已加载。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM