2

I've added the following parameter in Config.groovy

storeFront.cms.endpoint = "http://10.60.33.51:27110/file_source"

I'm trying to read it using:

ConfigurationHolder.config('storeFront.cms.endpoint')

I read somewhere that configuration parameters should be read using the grailsApplication variable that is available in taglibs and controllers, but in my case I'm trying to read it from a class under src/groovy.

When the application starts up I get the error:

groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigObject.call() 
is applicable for argument types: (java.lang.String) values: [storeFront.cms.endpoint]
Dónal
  • 185,044
  • 174
  • 569
  • 824

1 Answers1

4

Shouldn't that be:

ConfigurationHolder.config.storeFront.cms.endpoint

And yeah ConfigurationHolder is deprecated in Grails 2.0

tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • any idea what we're supposed to use instead of `ConfigurationHolder` when `grailsApplication` is not available? – Dónal Aug 15 '11 at 14:56
  • 1
    It's recommended that you use `def grailsApplication` injection method. However I don't believe this injection would occur for classes in `src/java` or `src/groovy`, so I guess you'd have to pass the `grailApplication` instance in from the controller/service/etc where you call the code? – tim_yates Aug 15 '11 at 15:03
  • Pass the `grailsApplication` or config to the src/groovy class - it has to be called from an artifact that has access to those. – Burt Beckwith Aug 15 '11 at 15:05