I am having problems when using dependency injection with Services in Grails.
class ExampleService{
def example2Service
def example3Service
def method1(){
def result = example2Service.method2()
}
}
class ExampleService{
def example3Service
def method2(){
def result = example3Service.method3()
return result
}
}
class Example3Service{
def method3(){
return true
}
}
Basically in Example2Service, I am getting a Null Pointer Exception when trying to call method3 in Example3Service.
I would appreciate any help than anybody can give me with this issue
thanks
Dependency Injection needs to be initialized. (The same applies to other kinds of runtime meta programming, like augmenting Domain classes with their
save()andvalidate()methods.)A Grails application will be initialized when
grails run-appcommandgrails test-appcommand (integration tests, only; unit tests do not trigger initialization).Involved classes are not initialized when
groovy,groovysh, orgroovyConsole)The following as an integration test should work: