Grails
  1. Grails
  2. GRAILS-8673

grailsApplication in Config.groovy, resource.groovy, XXXCodec.groovy, Searchable.groovy is null.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0 final, 2.0.1
    • Fix Version/s: None
    • Component/s: Configuration
    • Environment:
      ubuntu_11.04
      openjdk_1.6
      grails_2.0.0

      Description

      As I see, the ConfigurationHolder can be used in Config.groovy, resource.groovy, XXXCodec.groovy and Searchable.groovy. Maybe some others in grails-app/conf/.
      I see the ConfigurationHolder was deprecated now. But the grailsApplication is null in these files, I hope the grailsApplication can be used, I think it is useful.

        Activity

        Hide
        Ross Oreto added a comment -

        This is still an issue in grails 2.0.1, having to use AH.application.metadata.'app.name' instead of just appName. grailsApplication and appName are both null in Config.groovy.

        Show
        Ross Oreto added a comment - This is still an issue in grails 2.0.1, having to use AH.application.metadata.'app.name' instead of just appName. grailsApplication and appName are both null in Config.groovy.
        Hide
        Graeme Rocher added a comment -

        It is better to use Metadata.current.getApplicationName() in any case

        Show
        Graeme Rocher added a comment - It is better to use Metadata.current.getApplicationName() in any case
        Hide
        Silvère Lestang added a comment -

        I encounter this problem while trying to set some log4j config depending on the contextPath of my webapp.
        I try Metadata.current but it's also non-existent.
        Btw the documentation is false: http://grails.org/doc/latest/guide/conf.html#config specify that the file Config.groovy has a grailsApplication implicit variable.
        So are there somewhere a list of real implicit variables available inside Config.groovy?

        Show
        Silvère Lestang added a comment - I encounter this problem while trying to set some log4j config depending on the contextPath of my webapp. I try Metadata.current but it's also non-existent. Btw the documentation is false: http://grails.org/doc/latest/guide/conf.html#config specify that the file Config.groovy has a grailsApplication implicit variable. So are there somewhere a list of real implicit variables available inside Config.groovy ?
        Hide
        Silvère Lestang added a comment -

        After a little search I think it's a bug instead of an improvement, at least in recent version of Grails.
        In Grails 2.1.1 (Linux - Java 1.6.0_29) I see that ConfigurationHelper.getConfigSlurper() bind userHome, grailsHome, appName, appVersion and grailsApplication to the configSlurper.
        I try to display this variable with a println in Config.groovy and there are all set but grailsApplication. So I think it's a (weird) bug.

        Show
        Silvère Lestang added a comment - After a little search I think it's a bug instead of an improvement, at least in recent version of Grails. In Grails 2.1.1 (Linux - Java 1.6.0_29) I see that ConfigurationHelper.getConfigSlurper() bind userHome , grailsHome , appName , appVersion and grailsApplication to the configSlurper. I try to display this variable with a println in Config.groovy and there are all set but grailsApplication . So I think it's a (weird) bug.
        Hide
        Craig Sherstan added a comment -

        I'm using 2.2.0 and if I try to access grailsApplication I get an instance of ConfigObject, not null. Same if I try ApplicationHolder.application.

        Show
        Craig Sherstan added a comment - I'm using 2.2.0 and if I try to access grailsApplication I get an instance of ConfigObject, not null. Same if I try ApplicationHolder.application.

          People

          • Assignee:
            Unassigned
            Reporter:
            rainbow
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development