Question

I have installed the Grails Fixtures plugin (http://www.grails.org/plugin/fixtures) for loading some initial datas into my database for dev and test environment. I also use Grails with Maven integration.

I have added my data loading code into the BootStrap.groovy:

import grails.util.Environment

class BootStrap {
    def fixtureLoader

    def init = { servletContext ->

        if (Environment.current == Environment.DEVELOPMENT || Environment.current == Environment.TEST) {
            //def fixtureLoader = new FixtureLoader(grailsApplication)
            fixtureLoader.load("init")
        }
    }

}

When I run my Grails app with "grail run-app" it works perfectly, but if I use the Maven Grails command "mvn grails:run-app -Dgrails.env=development" then it doesn't work. It throws following error:

Error executing bootstraps; nested exception is java.lang.NullPointerException: Cannot invoke method load() on null object

It seems that the "fixtureLoader" bean is not correctly initialized if I use the Maven Grails command "mvn grails:run-app".

Do you have any idea? Or maybe its a bug...

Was it helpful?

Solution

Add it as a dependency in pom.xml instead of BuildConfig.groovy. Maven looks at the pom to resolve dependencies (in this case a plugin).

<dependency>
  <groupId>org.grails.plugins</groupId>
  <artifactId>fixtures</artifactId>
  <version>1.0.7</version>
  <scope>runtime</scope>
  <type>zip</type>
</dependency>

Note: scope runtime makes the artifact available in test scope as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top