Grails
  1. Grails
  2. GRAILS-9002

grailsApplication injection does not work for controller base class in some cases

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.2, 2.0.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      grailsApplication is not injected into controller base class in some cases.

      Test application is attached, just run with "grails dev run-app" and then try http://localhost:8080/grailsapp-inject-test/test

      Removing for example BaseController.c1 or BaseController.m1 or BaseController.m2 makes injection work.
      Removing TestInjectionController.s1 or TestInjectionController.test1 also makes injection work.
      Also adding @Autowired to def grailsApplication helps.

      When testing please make sure to run "grails clean" after each source code modification and running application.

        Activity

        Timur Yusupov created issue -
        Timur Yusupov made changes -
        Field Original Value New Value
        Status Open [ 1 ] Edit [ 10000 ]
        Affects Version/s 2.0.3 [ 13094 ]
        Jeff Scott Brown made changes -
        Assignee Jeff Brown [ brownj ]
        Hide
        Jeff Scott Brown added a comment -

        If you just remove the "def grailsApplication" from BaseController.groovy, does that give you the behavior that you want?

        Show
        Jeff Scott Brown added a comment - If you just remove the "def grailsApplication" from BaseController.groovy, does that give you the behavior that you want?
        Hide
        Timur Yusupov added a comment -

        Yes, exactly. Is it possible to add some warning in case of "def grailsApplication" is present in controller's code?
        What is confusing is that sometimes with "def grailsApplication" in base controller class all works fine, sometimes is not depending on strange conditions like set of methods and closures defined in classes.

        Show
        Timur Yusupov added a comment - Yes, exactly. Is it possible to add some warning in case of "def grailsApplication" is present in controller's code? What is confusing is that sometimes with "def grailsApplication" in base controller class all works fine, sometimes is not depending on strange conditions like set of methods and closures defined in classes.
        Burt Beckwith made changes -
        Status Edit [ 10000 ] Open [ 1 ]

          People

          • Assignee:
            Jeff Scott Brown
            Reporter:
            Timur Yusupov
          • Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development