flowable/flowable-engine · error · IllegalArgumentException
The field 'script' should be set on the TaskListener
Error message
The field 'script' should be set on the TaskListener
What it means
ScriptTypeTaskListener executes a script when a CMMN task/listener event fires. Before evaluating, validateParameters() (called from notify()) checks that both the 'script' and 'language' fields were configured; this error means the 'script' Expression field was never set on the listener definition.
Source
Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/ScriptTypeTaskListener.java:81
ScriptEngineRequest.Builder request = ScriptEngineRequest.builder()
.script(script)
.language(language)
.scopeContainer(delegateTask)
.traceEnhancer(trace -> trace.addTraceTag("type", "taskListener"));
Object result = scriptingEngines.evaluate(request.build()).getResult();
if (resultVariable != null) {
String resultVariable = Objects.toString(this.resultVariable.getValue(delegateTask), null);
if (resultVariable != null) {
delegateTask.setVariable(resultVariable, result);
}
}
}
protected void validateParameters() {
if (script == null) {
throw new IllegalArgumentException("The field 'script' should be set on the TaskListener");
}
if (language == null) {
throw new IllegalArgumentException("The field 'language' should be set on the TaskListener");
}
}
public void setScript(Expression script) {
this.script = script;
}
public void setLanguage(Expression language) {
this.language = language;
}
public void setResultVariable(Expression resultVariable) {
this.resultVariable = resultVariable;
}View on GitHub (pinned to d6d39ce1c6)
Solutions
- Add a field named 'script' with the script text/expression to the listener definition in the CMMN XML: <flowable:field name="script"><flowable:string><![CDATA[...]]></flowable:string></flowable:field>
- If building the listener programmatically, call setScript(expression) before deploying/executing
- Redeploy the corrected CMMN model and re-run the case
Example fix
// before
<flowable:taskListener event="complete" class="org.flowable.cmmn.engine.impl.listener.ScriptTypeTaskListener">
<flowable:field name="language" stringValue="javascript"/>
</flowable:taskListener>
// after
<flowable:taskListener event="complete" class="org.flowable.cmmn.engine.impl.listener.ScriptTypeTaskListener">
<flowable:field name="script"><flowable:string><![CDATA[println('done')]]></flowable:string></flowable:field>
<flowable:field name="language" stringValue="javascript"/>
</flowable:taskListener> Defensive patterns
Strategy: validation
Validate before calling
const fields = listenerDef.fields || {};
if (!fields.script || !fields.script.stringValue) throw new Error('ScriptTypeTaskListener: missing script field'); Type guard
function hasScript(l) { return l != null && l.script != null && l.script.expressionText != null; } Try / catch
try { deployModel(model); } catch (e) { if (String(e.message).includes("field 'script' should be set")) { fixListenerDefinition(model); } else { throw e; } } Prevention
- Always include both 'script' and 'language' fields in ScriptTypeTaskListener definitions
- Validate CMMN XML against the Flowable XSD before deployment
- Add a deploy-time smoke test that exercises each listener
When it happens
Trigger: A CMMN model declares a ScriptTypeTaskListener whose <flowable:field name="script"> element (or programmatic setScript) is missing, so script == null when notify() runs during plan-item/task event handling.
Common situations: Hand-edited or generated CMMN XML where the script field was omitted or misspelled (field name must be exactly 'script'); dynamically creating listener via code and forgetting setScript; model deployed from a template with placeholder script values left null.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- The field 'language' should be set on the TaskListener
- The field 'language' should be set on the TaskListener
- Could not find an implementation of the org.flowable.cdi.imp
- Programmatic error: task listener added to an element that i
- no SMTP host is configured for the default mail server
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/1d1f63d8288ff530.
Report an issue: GitHub.