Grails
  1. Grails
  2. GRAILS-1576

ApplicationHolder.getApplication() returns null during "grails test-app"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.6
    • Fix Version/s: 1.0-RC1
    • Component/s: Commons
    • Labels:
      None

      Description

      This affects code using this technique of obtaining the GrailsApplication, whether that code is called directly or indirectly whilst running tests.

      Possible unsatisfactory workarounds are multiple strategies for the different modes, or refactor such that get GrailsApplication is injected

        Activity

        Hide
        Ricardo J. Méndez added a comment -

        I'm getting this exact same error on Grails 1.1. Attaching very simple test project. When running grails test-app I get the following error on PrintHelper:

        Cannot get property 'config' on null object

        java.lang.NullPointerException: Cannot get property 'config' on null object
        at PrintHelper.printName(PrintHelper.groovy:7)

        Show
        Ricardo J. Méndez added a comment - I'm getting this exact same error on Grails 1.1. Attaching very simple test project. When running grails test-app I get the following error on PrintHelper: Cannot get property 'config' on null object java.lang.NullPointerException: Cannot get property 'config' on null object at PrintHelper.printName(PrintHelper.groovy:7)
        Hide
        Mike Nicholson added a comment -

        I too am observing this issue in v1.1 when attempting to follow the FAQ instructions: http://www.grails.org/FAQ#Q:%20How%20can%20I%20access%20domain%20classes%20from%20sources%20in%20src/groovy?

        Show
        Mike Nicholson added a comment - I too am observing this issue in v1.1 when attempting to follow the FAQ instructions: http://www.grails.org/FAQ#Q:%20How%20can%20I%20access%20domain%20classes%20from%20sources%20in%20src/groovy?
        Hide
        Ricardo J. Méndez added a comment -

        Can an issue be re-opened, or would it be appropriate to file a new bug?

        Show
        Ricardo J. Méndez added a comment - Can an issue be re-opened, or would it be appropriate to file a new bug?
        Hide
        Donal added a comment -

        I'm also seeing this problem in Grails 1.1.1. Has a new issue been created (I don't seem to have permission to re-open this one)?

        Show
        Donal added a comment - I'm also seeing this problem in Grails 1.1.1. Has a new issue been created (I don't seem to have permission to re-open this one)?
        Hide
        Ricardo J. Méndez added a comment -

        Consensus on the list seems to be that getting the application on unit tests should never have worked (even if it did up until 1.0.4 inclusive) and that any tests that use the application should be moved to integration tests.

        http://www.nabble.com/ApplicationHolder.getApplication%28%29-when-testing-%28GRAILS-1576%29-to23348283.html#a23348283

        Show
        Ricardo J. Méndez added a comment - Consensus on the list seems to be that getting the application on unit tests should never have worked (even if it did up until 1.0.4 inclusive) and that any tests that use the application should be moved to integration tests. http://www.nabble.com/ApplicationHolder.getApplication%28%29-when-testing-%28GRAILS-1576%29-to23348283.html#a23348283
        Hide
        Pablo Pazos Gutierrez added a comment -

        I'm working in 1.4.0.M1 and seeing the same behavior in unit testing that uses a class that access ApplicationHolder.application.config and says ApplicationHolder.application is null.

        Show
        Pablo Pazos Gutierrez added a comment - I'm working in 1.4.0.M1 and seeing the same behavior in unit testing that uses a class that access ApplicationHolder.application.config and says ApplicationHolder.application is null.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Maurice Nicholson
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development