{"record":{"id":"9806e9f59ee3b8cb","repo":"flowable/flowable-engine","slug":"messagename-cannot-be-null-9806e9","errorCode":null,"errorMessage":"messageName cannot be null","messagePattern":"messageName cannot be null","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/MessageEventReceivedCmd.java","lineNumber":67,"sourceCode":"            }\r\n\r\n        } else {\r\n            this.payload = null;\r\n        }\r\n        this.async = false;\r\n    }\r\n\r\n    public MessageEventReceivedCmd(String messageName, String executionId, boolean async) {\r\n        super(executionId);\r\n        this.messageName = messageName;\r\n        this.payload = null;\r\n        this.async = async;\r\n    }\r\n\r\n    @Override\r\n    protected Void execute(CommandContext commandContext, ExecutionEntity execution) {\r\n        if (messageName == null) {\r\n            throw new ActivitiIllegalArgumentException(\"messageName cannot be null\");\r\n        }\r\n\r\n        List<EventSubscriptionEntity> eventSubscriptions = commandContext.getEventSubscriptionEntityManager()\r\n                .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, executionId);\r\n\r\n        if (eventSubscriptions.isEmpty()) {\r\n            throw new ActivitiException(\"Execution with id '\" + executionId + \"' does not have a subscription to a message event with name '\" + messageName + \"'\");\r\n        }\r\n\r\n        // there can be only one:\r\n        EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptions.get(0);\r\n\r\n        eventSubscriptionEntity.eventReceived(payload, async);\r\n\r\n        return null;\r\n    }\r\n\r\n}\r","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/MessageEventReceivedCmd.java#L49-L85","documentation":"Thrown by MessageEventReceivedCmd.execute() when messageName is null. To deliver a message to a waiting execution, the engine must look up message event subscriptions by name, so a null name is rejected with ActivitiIllegalArgumentException.","triggerScenarios":"runtimeService.messageEventReceived(null, executionId) or messageEventReceived(null, executionId, payload); also trigger with async=true when constructing MessageEventReceivedCmd with null messageName.","commonSituations":"Message name read from a process variable or header that was not set; refactored caller dropped the name argument; configuration for the correlating message missing.","solutions":["Pass the message name that the receiving catch message event was declared with","Validate the name before calling (non-null, matches BPMN messageRef)","Log the intended message name at the call site to catch null-producing lookups"],"exampleFix":"// before\nruntimeService.messageEventReceived(messageName, executionId);\n// after\nif (messageName == null) throw new IllegalArgumentException(\"messageName required\");\nruntimeService.messageEventReceived(messageName, executionId);","handlingStrategy":"validation","validationCode":"if (messageName == null || messageName.isEmpty()) throw new IllegalArgumentException(\"messageName required\");","typeGuard":"boolean canDeliver(String messageName, String executionId) { return messageName != null && executionId != null; }","tryCatchPattern":"try { runtimeService.messageEventReceived(messageName, executionId, payload); } catch (ActivitiIllegalArgumentException e) { log.error(\"bad message correlation args\"); throw e; }","preventionTips":["Keep message names as constants matching BPMN messageRef","Validate correlation headers/variables before delivery","Log the resolved message name at trigger points"],"tags":["java","activiti","validation","null-argument","message-event"],"backgroundTag":"null-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"}