title: Grails java.lang.IllegalStateException: Method on class [] was used outside of a Grails application
body: <p>Grails version: 2.3.4</p>
  
  <p>Hibernate plugin: runtime ":hibernate:3.6.10.6"</p>
  
  <p>The line in Bootstrap.groovy that generates error:</p>
  
  <blockquote>
    <p>def adminRole = new Role(authority: 'ROLE_USER').save(flush: true)</p>
  </blockquote>
  
  <p>Actually any save operation in any class (controller, Bootstrap.groovy) results in this error.</p>
  
  <p>But when I get domain classes that are created in another computer, that works fine,no error.</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks. </p>
  
  <p>Full stacktrace:</p>
  
  <pre><code>ERROR context.GrailsContextLoader Error initializing the application: Method on class [com.hib.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
  java.lang.IllegalStateException: Method on class [com.hib.Role] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.
      at BootStrap$_closure1.doCall(BootStrap.groovy:9)
      at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
      at grails.util.Environment.executeForEnvironment(Environment.java:301)
      at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:744)
  </code></pre>
  
  <p>I am not using maven or mocking.</p>
  
  <p>Botstrap.groovy</p>
  
  <pre><code>    class BootStrap {
  
        def init = { servletContext -&gt;
  
        def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
  
     }
              def destroy = {
          }
      }
  </code></pre>