title: Method on class [] was used outside of a Grails application
body: <p>Previous questions on this error refer to a hibernate version issue or running a test.  I do not think this is the case here.</p>
  
  <p>In a Grails Service class I have:</p>
  
  <pre><code>private static User anon = User.findByUsername('anonymous')
  </code></pre>
  
  <p>and this is creating the error:</p>
  
  <pre><code>Caused by IllegalStateException: Method on class [User] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
  </code></pre>
  
  <p>I am trying to instantiate a private static attribute with an object stored in the database, but I must be doing something terribly wrong.  Thanks for any help, suggestions and pointers.</p>