Details
Description
I attached an example app to demonstrate this bug.
If you are calling a method from within a flow and this method is defined outside of the flow, you cannot access any controller-injected instances.
A workaround is to inject the service manually:
sample
...
def authenticationService
...
def isLoggedIn() {
def authenticationServiceClass = grailsApplication.classLoader.loadClass("AuthenticationService")
authenticationService = authenticationServiceClass.newInstance()
return authenticationService.authenticate()
}
I don't know if this issue also exists if you don't use a flow.
Issue Links
- is related to
-
GRAILS-7095
Dependency injection not working in webflows
-
To answer my question "I don't know if this issue also exists if you don't use a flow.":
No, it doesn't! If no flow is defined in the controller, everything works as expected...