I would like to access the Grails ConfigObject from within a static method and I tried to follow this article:
http://burtbeckwith.com/blog/?p=1017
The solution suggests to create a custom Application Context holder using a singleton class and register that in the beans list (resources.groovy).
The singleton class should have a private attribute of type ApplicationContext that should be initialized by the setApplicationContext method but it looks like that never happens.
How can I set ApplicationContext in my singleton class instance?
It depends when you are trying to access it – if your static method is called before the grailsApplication has been fully set up then it may not yet have been injected. Try using
grails.util.Holders(the non-deprecated replacement for ApplicationHolder et al) or try the “domain class trick”