{"record":{"id":"5d541706ffbcbae6","repo":"flowable/flowable-engine","slug":"the-field-script-should-be-set-on-the-executionl","errorCode":null,"errorMessage":"The field 'script' should be set on the ExecutionListener","messagePattern":"The field 'script' should be set on the ExecutionListener","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/listener/ScriptExecutionListener.java","lineNumber":36,"sourceCode":"import org.flowable.common.engine.api.delegate.Expression;\nimport org.flowable.engine.delegate.DelegateExecution;\nimport org.flowable.engine.delegate.ExecutionListener;\n\npublic class ScriptExecutionListener implements ExecutionListener {\n\n    private static final long serialVersionUID = 1L;\n\n    private Expression script;\n\n    private Expression language;\n\n    private Expression resultVariable;\n\n    @Override\n    public void notify(DelegateExecution execution) {\n\n        if (script == null) {\n            throw new IllegalArgumentException(\"The field 'script' should be set on the ExecutionListener\");\n        }\n\n        if (language == null) {\n            throw new IllegalArgumentException(\"The field 'language' should be set on the ExecutionListener\");\n        }\n\n        ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();\n\n        Object result = scriptingEngines.evaluate(script.getExpressionText(), language.getExpressionText(), execution);\n\n        if (resultVariable != null) {\n            execution.setVariable(resultVariable.getExpressionText(), result);\n        }\n    }\n\n    public void setScript(Expression script) {\n        this.script = script;\n    }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/listener/ScriptExecutionListener.java#L18-L54","documentation":"Thrown as a plain IllegalArgumentException from ScriptExecutionListener.notify when the listener's 'script' field (an Expression set via <activiti:field name=\"script\">) is null. The listener needs a script to evaluate and refuses to run without one.","triggerScenarios":"An <activiti:executionListener class=\"...ScriptExecutionListener\"/> (or delegateExpression to it) is declared without the <activiti:field name=\"script\"> element, or the field element has an empty/invalid expression so the injected Expression is null.","commonSituations":"Copy-pasting a ScriptExecutionListener declaration and forgetting the script field; using field name \"script\" misspelled (e.g. \"scriptValue\"); declaring the listener programmatically without calling setScript; XML where the field's string/expression child is missing.","solutions":["Add the script field to the listener declaration: <activiti:field name=\"script\"><activiti:string>your script</activiti:string></activiti:field>.","Check the field name is exactly \"script\" and matches the listener's setScript property.","If configuring programmatically, call setScript(expression) with a non-null Expression before execution.","Ensure the field element actually contains a value (string or expression child), not an empty tag."],"exampleFix":"// before: missing script field\n<activiti:executionListener event=\"start\" class=\"org.activiti.engine.impl.bpmn.listener.ScriptExecutionListener\">\n  <activiti:field name=\"language\" value=\"javascript\"/>\n</activiti:executionListener>\n\n// after\n<activiti:executionListener event=\"start\" class=\"org.activiti.engine.impl.bpmn.listener.ScriptExecutionListener\">\n  <activiti:field name=\"language\" value=\"javascript\"/>\n  <activiti:field name=\"script\"><activiti:string>execution.setVariable('x', 1);</activiti:string></activiti:field>\n</activiti:executionListener>","handlingStrategy":"validation","validationCode":"// validate the listener XML has both required fields before deployment\n// e.g. parse the bpmn and check every ScriptExecutionListener declaration\nassertListenerHasField(processDefinitionXml, \"ScriptExecutionListener\", \"script\");","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.createDeployment().addInputStream(\"p.bpmn\", xml).deploy();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"The field 'script' should be set\")) {\n        logger.error(\"ScriptExecutionListener missing <activiti:field name=\\\"script\\\">\");\n    }\n    throw e;\n}","preventionTips":["Always include both 'script' and 'language' field elements in ScriptExecutionListener declarations.","Use an XML schema/BPMN lint to check listener field completeness before deployment.","Keep a snippet/template for script listeners in project docs.","Verify field names exactly match the listener's setters (script, language, resultVariable)."],"tags":["bpmn","scripting","listener","missing-field"],"backgroundTag":"missing-required-config-field","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"}