Question

I have the following code in Bootstrap.groovy :-

class BootStrap {

    def dataLoaders;

    def init = { servletContext ->
        startLoaders();
    }


    def startLoaders() {
        for (IDataLoader loader : dataLoaders) {
            runAsync {
                loader.setup();
                loader.startLoading();
            }
        }
    }
}

When I run the application, the following exception is thrown:

ERROR org.codehaus.groovy.grails.web.context.GrailsContextLoader Error initializing the application: No signature of method: BootStrap.runAsync() is applicable for argument types: (BootStrap$_startLoaders_closure3) values: [BootStrap$_startLoaders_closure3@6892f97b]
groovy.lang.MissingMethodException: No signature of method: BootStrap.runAsync() is applicable for argument types: (BootStrap$_startLoaders_closure3) values: [BootStrap$_startLoaders_closure3@6892f97b]
    at BootStrap.startLoaders(BootStrap.groovy:27)
    at BootStrap$_closure1.doCall(BootStrap.groovy:15)

I have already added the following to the plugins section of BuildConfig.groovy:

compile ":executor:0.3"
Was it helpful?

Solution

Try this instead:

class BootStrap {

    def dataLoaders
    def executorService

    def init = { servletContext ->
        startLoaders()
    }

    def startLoaders() {
        for (IDataLoader loader : dataLoaders) {
            executorService.submit({
                loader.setup()
                loader.startLoading()
            } as Callable)
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top