WELCOME Abdennour : Software engineer

May 8, 2013

Load and use fixture in grails console

i excute the following code via grails console instead of BootStrap :
class BootStrap {
def fixtureLoader

    def init = { servletContext ->


I get the following error :
java.lang.NullPointerException: Cannot invoke method load() on null object
    at Script1.run(Script1.groovy:16)
    at org.grails.plugins.console.ConsoleService.eval(ConsoleService.groovy:57)
    at org.grails.plugins.console.ConsoleService.eval(ConsoleService.groovy:37)
    at org.grails.plugins.console.ConsoleController$_closure2.doCall(ConsoleController.groovy:61)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)
How can i use console to load fixtures


DI(dependency injection) is done automatically in grails through the pattern CoC.
So if you copy / paste the code, the console will not inject the dependency. So it must be injected manually by calling the foctory ctx.getBean ('')
def fixtureLoader=ctx.getBean('fixtureLoader');


See my Answer here

No comments:

Post a Comment