#StackBounty: #grails Grails 4.0.11 run-script gives error Context failed to load: null

Bounty: 50

I created this groovy script src/scripts/test.groovy

println "hello"

Running this with grails run-script src/scripts/test.groovy gives this error:

Task :runScript FAILED
<=============> 100% EXECUTING [19s]
IDLE
Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.UnsupportedOperationException
at org.codehaus.groovy.control.CompilerConfiguration$1.addCompilationCustomizers(CompilerConfiguration.java:173)
at grails.ui.script.GrailsApplicationScriptRunner.run(GrailsApplicationScriptRunner.groovy:61)
at grails.ui.script.GrailsApplicationScriptRunner.main(GrailsApplicationScriptRunner.groovy:122)
… 5 more
Context failed to load: null <<<<<<<<<<<<<

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:runScript’.

Process ‘command ‘/home/avorsterman/.sdkman/candidates/java/8.0.292.j9-adpt/bin/java” finished with non-zero exit value 1
`

grails -v

| Grails Version: 4.0.11 | JVM Version: 1.8.0_292

I’m using Groovy version 2.5.14

Full stacktrace at https://pastebin.com/zqfMUm5j

How can I fix this?

Update

I have the same error when installing Grails 4.0.10, 4.0.0 and 5.0.0.RC1

Only using 3.3.14 the script runs without error

grails run-script scripts/test.groovy 
:compileJava NO-SOURCE
:compileGroovy UP-TO-DATE
:buildProperties UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:runScript
hello

BUILD SUCCESSFUL

Total time: 22.357 secs

I did one more test:
I launched a new AWS EC2 Ubuntu 20 instance.
Installed sdkman

sdk install java 8.0.292.hs-adpt  
sdk install grails 4.0.11  
grails create-app myapp  
cd myapp  
mkdir scripts  
echo 'println "hello world"' > scripts/test.groovy 
grails run-script scripts/test.groovy

Same error:
Context failed to load: null


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.