{"record":{"id":"961d65aa6b563d84","repo":"flowable/flowable-engine","slug":"the-field-script-should-be-set-on-the-tasklisten-961d65","errorCode":null,"errorMessage":"The field 'script' should be set on the TaskListener","messagePattern":"The field 'script' should be set on the TaskListener","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/listener/ScriptTaskListener.java","lineNumber":41,"sourceCode":" * @author Rich Kroll\n * @author Joram Barrez\n */\npublic class ScriptTaskListener implements TaskListener {\n\n    private static final long serialVersionUID = -8915149072830499057L;\n\n    protected Expression script;\n\n    protected Expression language;\n\n    protected Expression resultVariable;\n\n    protected boolean autoStoreVariables;\n\n    @Override\n    public void notify(DelegateTask delegateTask) {\n        if (script == null) {\n            throw new IllegalArgumentException(\"The field 'script' should be set on the TaskListener\");\n        }\n\n        if (language == null) {\n            throw new IllegalArgumentException(\"The field 'language' should be set on the TaskListener\");\n        }\n\n        ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();\n\n        Object result = scriptingEngines.evaluate(script.getExpressionText(), language.getExpressionText(), delegateTask, autoStoreVariables);\n\n        if (resultVariable != null) {\n            delegateTask.setVariable(resultVariable.getExpressionText(), result);\n        }\n    }\n\n    public void setScript(Expression script) {\n        this.script = script;\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/listener/ScriptTaskListener.java#L23-L59","documentation":"ScriptTaskListener requires a 'script' field expression to know what script to execute when the task listener fires. If the 'script' field was not configured on the listener in the BPMN XML, notify() throws this IllegalArgumentException immediately when the listener is invoked.","triggerScenarios":"A script task listener is declared in BPMN XML (or via listener configuration) without an <activiti:field name='script'> element, and the listener fires on a task event (create/assignment/complete/delete).","commonSituations":"Hand-edited BPMN XML missing the script field extension element; programmatically built listeners where setScript was never called; copy-pasted listener configs where the script field was accidentally removed.","solutions":["Add a <activiti:field name='script'><activiti:string>...script text...</activiti:string></activiti:field> to the task listener declaration in the BPMN XML","If building the listener in code, call setScript with a FixedValue or Expression before deployment","Validate the process definition at deploy time to catch missing listener fields before runtime"],"exampleFix":"// before (BPMN)\n<activiti:taskListener event=\"create\" class=\"org.activiti.engine.impl.bpmn.listener.ScriptTaskListener\" />\n// after\n<activiti:taskListener event=\"create\" class=\"org.activiti.engine.impl.bpmn.listener.ScriptTaskListener\">\n  <activiti:field name=\"script\">\n    <activiti:string>println(task.name)</activiti:string>\n  </activiti:field>\n  <activiti:field name=\"language\">\n    <activiti:string>javascript</activiti:string>\n  </activiti:field>\n</activiti:taskListener>","handlingStrategy":"validation","validationCode":"// XML check before deployment\nif (!xml.contains(\"name=\\\"script\\\"\")) {\n  throw new IllegalStateException(\"ScriptTaskListener is missing the 'script' field\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  repositoryService.createDeployment().addClasspathResource(processXml).deploy();\n} catch (IllegalArgumentException e) {\n  // listener fields incomplete — fix BPMN config and redeploy\n}","preventionTips":["Always pair ScriptTaskListener with both 'script' and 'language' fields","Use a BPMN XSD validation step in CI for all process definitions","Centralize listener definitions as reusable snippets to avoid omissions"],"tags":["bpmn","task-listener","configuration","groovy-or-script"],"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-14T05:17:10.506Z"}