Grails version: 2.3.4
Hibernate plugin: runtime ":hibernate:3.6.10.6"
The line in Bootstrap.groovy that generates error:
def adminRole = new Role(authority: 'ROLE_USER').save(flush: true)
Actually any save operation in any class (controller, Bootstrap.groovy) results in this error.
But when I get domain classes that are created in another computer, that works fine,no error.
Any suggestions?
Thanks.
Full stacktrace:
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)
I am not using maven or mocking.
Botstrap.groovy
class BootStrap {
def init = { servletContext ->
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
}
def destroy = {
}
}
Bootstrap.groovy
? Sounds like you're running a closure outside of theinit
closure – tim_yates