Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access grailsApplication or Service in groovy class

I am trying to access grailsApplication in groovy class under src/groovy but I get a null pointer exception. I also tried to inject a service into the same class and same result. How can I access grailsApplication or a service from groovy class? (I am using Grails 1.3.7)

like image 910
Eddard Stark Avatar asked Jan 17 '13 08:01

Eddard Stark


1 Answers

After Grails 2.0, you should use:

 def grailsApplication = Holders.grailsApplication
like image 190
GSAN Avatar answered Oct 08 '22 06:10

GSAN