flowable/flowable-engine · error · FlowableIllegalStateException

The field 'script' should be set on " +…

Error message

The field 'script' should be set on " + getClass().getSimpleName()

What it means

Parameter guard in AbstractScriptEvaluator.validateParameters: the script source expression resolves to null/empty, so there is no code for the script engine to evaluate; the guard fires before engine selection with the evaluator class name in the message.

Solutions

  1. Set a non-empty 'script' field on the script task/listener configuration
  2. Verify the script text or expression resolves against the available variables

Example fix

// before
GroovyScriptEvaluator eval = new GroovyScriptEvaluator();
eval.setLanguage("groovy");
// after
GroovyScriptEvaluator eval = new GroovyScriptEvaluator();
eval.setLanguage("groovy");
eval.setScript("return input * 2;");
Defensive patterns

Strategy: validation

Validate before calling

if (evaluator.getScript() == null) {
    throw new IllegalStateException("script property not injected on " + evaluator.getClass().getSimpleName());
}

Try / catch

try {
    return evaluator.createScriptRequest(variableContainer).build();
} catch (FlowableIllegalStateException e) {
    if (e.getMessage().contains("field 'script'")) {
        throw new IllegalStateException("Configure the script property on " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Programmatically creating an AbstractScriptEvaluator subclass (or binding one via BPMN) without calling setScript(...), then invoking createScriptRequest()/evaluate.

Common situations: Custom JavaDelegate/listener wired in Spring without injecting the script property; BPMN XML missing the script body; refactoring removed setScript initialization.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/e11232b5702f055e. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/scripting/AbstractScriptEvaluator.java:99

        Object result = evaluateScript(getScriptingEngines(), request);

        if (resultVariable != null) {
            VariableContainer variableContainer = request.getScopeContainer();
            String resultVariable = Objects.toString(this.resultVariable.getValue(variableContainer), null);
            if (variableContainer != null && resultVariable != null) {
                variableContainer.setVariable(resultVariable, result);
            }
        }
        return result;
    }

    protected Object evaluateScript(ScriptingEngines scriptingEngines, ScriptEngineRequest request) {
        return scriptingEngines.evaluate(request).getResult();
    }

    protected void validateParameters() {
        if (script == null) {
            throw new FlowableIllegalStateException("The field 'script' should be set on " + getClass().getSimpleName());
        }

        if (language == null) {
            throw new FlowableIllegalStateException("The field 'language' should be set on " + getClass().getSimpleName());
        }
    }

    protected abstract ScriptingEngines getScriptingEngines();

    public void setScript(String script) {
        this.script = script;
    }

    /**
     * Sets the script as Expression for backwards compatibility.
     * Requires to for 'field' injection of scripts.
     * Expression is not evaluated
     */

View on GitHub (pinned to d6d39ce1c6)