{"record":{"id":"6dc9e9ddf245e4d5","repo":"flowable/flowable-engine","slug":"problem-evaluating-script-e-getmessage","errorCode":null,"errorMessage":"problem evaluating script: ${e.getMessage()}","messagePattern":"problem evaluating script: (.+?)","errorType":"exception","errorClass":"org.activiti.engine.ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/scripting/ScriptingEngines.java","lineNumber":89,"sourceCode":"\n    public Object evaluate(String script, String language, VariableScope variableScope, boolean storeScriptVariables) {\n        return evaluate(script, language, createBindings(variableScope, storeScriptVariables));\n    }\n\n    public void setCacheScriptingEngines(boolean cacheScriptingEngines) {\n        this.cacheScriptingEngines = cacheScriptingEngines;\n    }\n\n    public boolean isCacheScriptingEngines() {\n        return cacheScriptingEngines;\n    }\n\n    protected Object evaluate(String script, String language, Bindings bindings) {\n        ScriptEngine scriptEngine = getEngineByName(language);\n        try {\n            return scriptEngine.eval(script, bindings);\n        } catch (ScriptException e) {\n            throw new ActivitiException(\"problem evaluating script: \" + e.getMessage(), e);\n        }\n    }\n\n    protected ScriptEngine getEngineByName(String language) {\n        ScriptEngine scriptEngine = null;\n\n        if (cacheScriptingEngines) {\n            scriptEngine = cachedEngines.get(language);\n            if (scriptEngine == null) {\n                scriptEngine = scriptEngineManager.getEngineByName(language);\n\n                if (scriptEngine != null) {\n                    // ACT-1858: Special handling for groovy engine regarding GC\n                    if (GROOVY_SCRIPTING_LANGUAGE.equals(language)) {\n                        try {\n                            scriptEngine.getContext().setAttribute(\"#jsr223.groovy.engine.keep.globals\", \"weak\", ScriptContext.ENGINE_SCOPE);\n                        } catch (Exception ignore) {\n                            // ignore this, in case engine doesn't support the passed attribute","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/scripting/ScriptingEngines.java#L71-L107","documentation":"ScriptingEngines.evaluate executes a script with the engine resolved for the given language via scriptEngine.eval. Any ScriptException (syntax errors, runtime script errors, engine failures) is wrapped and rethrown as ActivitiException with the original message plus the cause.","triggerScenarios":"Calling evaluate(script, language, bindings) (directly or via script task / condition / listener) where scriptEngine.eval throws a ScriptException — script syntax error, undefined variable access, script engine runtime failure, or unsupported language causing a bad engine invocation.","commonSituations":"Groovy/JS scripts with typos, referencing variables not present in the bindings/variable scope, script engine missing from classpath (no Groovy dependency) so resolution or eval fails, incompatible script syntax after switching language attribute, restricted environment blocking script compilation.","solutions":["Read the wrapped cause (getCause()) and the embedded message to find the actual script line/error.","Test the script standalone in the same language and engine version used by the process engine.","Verify all variables used in the script exist in the execution/bindings scope at that point.","Confirm the language's engine jar (e.g. groovy-all, nashorn for JS on newer JDKs) is on the classpath and compatible with the JDK version."],"exampleFix":"// before\n<flowable:executionListener event=\"start\" expression=\"${summy.groovy}\" /> // typo'd script var x = y +;\n// after\n<flowable:executionListener event=\"start\">\n  <flowable:script language=\"groovy\">def x = 1 + 2\nreturn x</flowable:script>\n</flowable:executionListener>","handlingStrategy":"try-catch","validationCode":"// pre-validate script compiles with the same engine\nScriptEngine engine = new ScriptEngineManager().getEngineByName(language);\nif (engine == null) throw new IllegalStateException(\"no script engine for \" + language);\nengine.eval(script, new SimpleBindings()); // throws early if syntax broken","typeGuard":null,"tryCatchPattern":"try {\n    return scriptingEngines.evaluate(script, language, bindings);\n} catch (ActivitiException e) {\n    logger.error(\"script eval failed: {} cause: {}\", e.getMessage(), e.getCause(), e);\n    throw e;\n}","preventionTips":["Syntax-check scripts in CI using the same engine and language version.","Ensure the script engine jars (groovy/nashorn) are on the classpath and JDK-compatible.","Validate that every variable referenced by scripts exists in the execution scope."],"tags":["scripting","script-exception","groovy","javascript"],"backgroundTag":"invalid-config-value","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}