title: Use grailsApplication injection inside UrlMappings
body: <p>For some reason I get a huge list of errors when using following code:</p>
  
  <pre><code>class UrlMappings {
      static grailsApplication
      static mappings = {
  
      grailsApplication.controllerClasses.each { controllerClass -&gt; // FAILS!
          println(controllerClass.name)
      }
  
      "/$controller/$action?/$id?"{}
  
      "/"(view:"/index")
      "500"(view:'/error')
  }
  </code></pre>
  
  <p>Errors: <a href="http://pastebin.com/tiEsENie" rel="nofollow">http://pastebin.com/tiEsENie</a></p>
  
  <hr>
  
  <p>Where as following code works just fine and prints all the controller names:</p>
  
  <pre><code>class UrlMappings {
      static grailsApplication
  static mappings = {
  
      "/$controller/$action?/$id?"{
          grailsApplication.controllerClasses.each { controllerClass -&gt; // WORKS!
              println(controllerClass.name)
          }
      }
  
      "/"(view:"/index")
      "500"(view:'/error')
  }
  }
  </code></pre>
  
  <p>Isn't it possible to access the static <code>grailsApplication</code> from inside <code>static mappings</code>?</p>
  
  <p>(I need to be able to get the controller names in order to dynamically create urlmappings)</p>