|
In grails 2.0.4 I have a basic script containing only:
println "HelloWorld" When I execute this script with the runScript command, it blows up with the NoSuchMethodError below. Any ideas? Workarounds? Blindly obvious errors I've made? grails run-script otherScripts/HelloWorld.groovy
| Error Error executing script RunScript: org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;
java.lang.NoSuchMethodError: org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;
at org.codehaus.groovy.grails.commons.spring.GrailsApplicationContext.prepareBeanFactory(GrailsApplicationContext.java:169)
at org.codehaus.groovy.grails.commons.spring.GrailsWebApplicationContext.prepareBeanFactory(GrailsWebApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:400)
at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:153)
at grails.spring.BeanBuilder.createApplicationContext(BeanBuilder.java:578)
at grails.spring.BeanBuilder$createApplicationContext.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at _GrailsBootstrap_groovy$_run_closure1.doCall(_GrailsBootstrap_groovy:58)
Thanks Tim.. |
|
A couple things... First, I don't think you can have scripts be in sub-folder under "scripts", but not a 100% sure. You can include other scripts in sub-folders via includeTargets though:
includeTargets << new File("/path/to/my/script.groovy") Second, you don't use "run-script" to execute scripts, it's simply the name of the script. So, if you have a script called HelloWorld.groovy under the scripts directory, you would execute it via "grails hello-world" Third, you need to define a default target for the script to work properly. So, something like this for a hello world example: includeTargets << grailsScript("_GrailsInit") target(main: "hello") { println "hello world" } setDefaultTarget(main) Hope that helps! Bobby |
|
run-script is new and different from running Gant scripts; see http://grails.org/doc/latest/ref/Command%20Line/run-script.html
Burt
|
|
In reply to this post by Tim R
This works for me in a new empty 2.0.4 app. It looks like a classpath problem - the missing method is there in Spring 3.1. Something (probably a plugin) must be dragging in older Spring jars. Try "grails clean" and "grails compile", and look at a dependency report if that doesn't work.
Burt
|
| Powered by Nabble | Edit this page |
