Reputation: 18649
When I deploy my grails generated war file to jetty I get the following error. My question is how de we tell grails where to look for this config file? It works fine for grails run-app because its run from project base where this file exists but gives this error when running withing jetty.
org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper - Unable to load specified config location file:./grails-app/conf/something-config.properties
Upvotes: 1
Views: 3058
Reputation: 75671
If you're bundling the file in with the war, then putting it in grails-app/conf
should put it in the root of the classpath. Move it to src/java
if it doesn't, since that will definitely work both with run-app and in a war. Then register it as an external config in Config.groovy:
grails.config.locations = ["classpath:something-config.properties"]
If you want to deploy it separately from the war (for example to have one war that works in multiple deployments each with its own config file) then you would make the same change to Config.groovy, but copy it to somewhere in Jetty's classpath. I'm not that familiar with Jetty, but I know that Tomcat's lib dir is in its classpath, so I put files like this there. I assume there's an analagous location for Jetty where you can put jars and resources that should be loaded.
Upvotes: 2
Reputation: 15673
It's a good question. My Config.groovy has these lines commented out. I wonder if yours has a special external config you are trying to read:
// locations to search for config files that get merged into the main config
// config files can either be Java properties files or ConfigSlurper scripts
// grails.config.locations = [ "classpath:${appName}-config.properties",
// "classpath:${appName}-config.groovy",
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]
// if(System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
Upvotes: 1