In my Java8 Spring boot application that has a dependency on groovy-json
library version 3.0.19 to execute groovy scripts, it fails with below exception when my application war file is deployed in Tomcat, but not in Docker or local development setup. On execution of script like new groovy.json.JsonSlurper().parseText('{}')
I see below exception:
'javax.script.ScriptException: java.lang.RuntimeException: Unable to load FastStringService'
Above runtime exception is from this portion of code in groovy-json package: https://github.com/apache/groovy/blob/GROOVY_3_0_19/subprojects/groovy-json/src/main/java/org/apache/groovy/json/internal/FastStringUtils.java#L35-L59
I've looked for conflicting dependencies, there is only this version of groovy-json library in my app. The particular class in question does actually exist in my artifact. Any ideas on this error?
Updates:
Stacktrace:
"org.flowable.common.engine.impl.scripting.FlowableScriptEvaluationException: groovy script evaluation failed: 'javax.script.ScriptException: org.flowable.common.engine.impl.scripting.FlowableScriptEvaluationException: groovy script evaluation failed: 'javax.script.ScriptException: java.lang.RuntimeException: Unable to load FastStringService''",
" at org.flowable.common.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:132)",
"Caused by: javax.script.ScriptException: javax.script.ScriptException: java.lang.RuntimeException: Unable to load FastStringService",
" at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:158)",
" at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)",
" at org.flowable.common.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:111)",
" ... 152 more",
"Caused by: javax.script.ScriptException: java.lang.RuntimeException: Unable to load FastStringService",
" at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320)",
" at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)",
" ... 154 more",
"Caused by: java.lang.RuntimeException: Unable to load FastStringService",
" at org.apache.groovy.json.internal.FastStringUtils.getService(FastStringUtils.java:56)",
" at org.apache.groovy.json.internal.FastStringUtils.toCharArray(FastStringUtils.java:66)",
" at org.apache.groovy.json.internal.BaseJsonParser.parse(BaseJsonParser.java:113)",
" at groovy.json.JsonSlurper.parseText(JsonSlurper.java:204)",
" at groovy.json.JsonSlurper$parseText.call(Unknown Source)",
" at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)",
" at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)",
" at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)",
" at Script449.run(Script449.groovy:2)",
" at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)",
" ... 155 more"```
Tomcat version: 9.0.71
Sometimes, the compiler finds it difficult to resolve dependencies when source code for java and groovy is in more than one source dir, so you can tell gradle/the compiler where to find the source to compile for the project by adding the following to your
build.gradle
: