title: grailsApplication null in Service
body: <p>I have a Service in my Grails application. However I need to reach the config for some configuration in my application. But when I am trying to use <code>def grailsApplication</code> in my Service it still gets null.</p>
  
  <p>My service is under "Services".</p>
  
  <pre><code>class RelationService {
  
      def grailsApplication
  
      private String XML_DATE_FORMAT = "yyyy-MM-dd"
      private String token = 'hej123'
      private String tokenName
      String WebserviceHost = 'xxx'
  
      def getRequest(end_url) {
  
          // Set token and tokenName and call communicationsUtil
          setToken();
          ComObject cu = new ComObject(tokenName)
  
          // Set string and get the xml data
          String url_string = "http://" + WebserviceHost + end_url
          URL url = new URL(url_string)
  
          def xml = cu.performGet(url, token)
  
          return xml
      }
  
      private def setToken() {
          tokenName = grailsApplication.config.authentication.header.name.toString()
          try {
              token = RequestUtil.getCookie(grailsApplication.config.authentication.cookie.token).toString()
          }
          catch (NoClassDefFoundError e) {
              println "Could not set token, runs on default instead.. " + e.getMessage()
          }
          if(grailsApplication.config.webservice_host[GrailsUtil.environment].toString() != '[:]')
              WebserviceHost = grailsApplication.config.webservice_host[GrailsUtil.environment].toString()
  
      }
  
  }
  </code></pre>
  
  <p>I have looked on <a href="https://stackoverflow.com/questions/4973919/inject-grails-application-configuration-into-service">Inject grails application configuration into service</a> but it doesn't give me an answer as everything seems correct. </p>
  
  <p>However I call my Service like this: <code>def xml = new RelationService().getRequest(url)</code> </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Forgot to type my error, which is: <code>Cannot get property 'config' on null object</code></p>