{"record":{"id":"7f5a679bcd917281","repo":"flowable/flowable-engine","slug":"no-event-defined-for-tasklistener-in-usertask","errorCode":null,"errorMessage":"No event defined for taskListener in UserTask '\" + userTask.getName() + \"'. Line: \" + listener.getXmlRowNumber()","messagePattern":"No event defined for taskListener in UserTask '\" \\+ userTask\\.getName\\(\\) \\+ \"'\\. Line: \" \\+ listener\\.getXmlRowNumber\\(\\)","errorType":"validation","errorClass":"FlowableIllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java","lineNumber":119,"sourceCode":"        addTransactionListener(listener, new ExecuteExecutionListenerTransactionListener(executionListener, scope, \n                        CommandContextUtil.getProcessEngineConfiguration().getCommandExecutor()));\n    }\n\n    public void executeTaskListeners(TaskEntity taskEntity, String eventType) {\n        if (taskEntity.getProcessDefinitionId() != null) {\n            org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId());\n            FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true);\n            if (flowElement instanceof UserTask userTask) {\n                executeTaskListeners(userTask, taskEntity, eventType);\n            }\n        }\n    }\n\n    public void executeTaskListeners(UserTask userTask, TaskEntity taskEntity, String eventType) {\n        for (FlowableListener listener : userTask.getTaskListeners()) {\n            String event = listener.getEvent();\n            if (event == null) {\n                throw new FlowableIllegalStateException(\n                        \"No event defined for taskListener in UserTask '\" + userTask.getName() + \"'. Line: \" + listener.getXmlRowNumber());\n            }\n            if (event.equals(eventType) || event.equals(TaskListener.EVENTNAME_ALL_EVENTS)) {\n                BaseTaskListener taskListener = createTaskListener(listener);\n\n                if (listener.getOnTransaction() != null) {\n                    ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager().findById(taskEntity.getExecutionId());\n                    planTransactionDependentTaskListener(executionEntity, (TransactionDependentTaskListener) taskListener, listener);\n                } else {\n                    taskEntity.setEventName(eventType);\n                    taskEntity.setEventHandlerId(listener.getId());\n                    \n                    try {\n                        CommandContextUtil.getProcessEngineConfiguration().getDelegateInterceptor()\n                                .handleInvocation(new TaskListenerInvocation((TaskListener) taskListener, taskEntity));\n                    } finally {\n                        taskEntity.setEventName(null);\n                    }","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/listener/ListenerNotificationHelper.java#L101-L137","documentation":"When executing task listeners for a user task, ListenerNotificationHelper checks that each FlowableListener declares an event. If listener.getEvent() is null, it throws FlowableIllegalStateException, because without an event the listener can never be matched to a lifecycle moment.","triggerScenarios":"A <flowable:taskListener> element in the BPMN XML is missing the required 'event' attribute (e.g. <flowable:taskListener class=\"...\"/> with no event=\"create|assignment|complete|delete|all\").","commonSituations":"Hand-edited or generated BPMN XML omitting the event attribute; modeler export dropping the attribute; listener added programmatically via builder without .event(...).","solutions":["Add the event attribute to the taskListener element in the BPMN XML (event=\"create\", \"assignment\", \"complete\", \"delete\", or \"all\")","If adding listeners in code, call .event(TaskListener.EVENTNAME_ALL_EVENTS) or a specific event on the listener builder","Validate the deployed XML against the flowable XSD before deployment to catch the missing attribute"],"exampleFix":"// before\n<flowable:taskListener class=\"com.example.MyListener\" />\n// after\n<flowable:taskListener event=\"create\" class=\"com.example.MyListener\" />","handlingStrategy":"validation","validationCode":"for (FlowableListener l : userTask.getTaskListeners()) {\n    if (l.getEvent() == null) throw new IllegalStateException(\"taskListener missing event attr in \" + userTask.getId());\n}","typeGuard":"boolean hasEvent(FlowableListener l) { return l.getEvent() != null; }","tryCatchPattern":"try {\n    runtimeService.startProcessInstanceByKey(\"myProcess\");\n} catch (FlowableIllegalStateException e) {\n    if (e.getMessage().startsWith(\"No event defined for taskListener\")) {\n        log.error(\"BPMN XML has taskListener without event attribute: {}\", e.getMessage());\n    }\n}","preventionTips":["Always set event (or \"all\") on every taskListener element","Validate BPMN XML against the Flowable XSD before deployment","Use the Flowable Modeler which enforces the event attribute"],"tags":["bpmn","task-listener","missing-attribute"],"backgroundTag":"missing-required-argument","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"}