{"record":{"id":"2a71da7b47af7327","repo":"flowable/flowable-engine","slug":"could-not-find-matching-flowelement-for-events","errorCode":null,"errorMessage":"Could not find matching FlowElement for \" + eventSubscription","messagePattern":"Could not find matching FlowElement for \" \\+ eventSubscription","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/SignalEventHandler.java","lineNumber":61,"sourceCode":"    public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {\r\n        if (eventSubscription.getExecutionId() != null) {\r\n            super.handleEvent(eventSubscription, payload, commandContext);\r\n\r\n        } else if (eventSubscription.getProcessDefinitionId() != null) {\r\n\r\n            // Find initial flow element matching the signal start event\r\n            String processDefinitionId = eventSubscription.getProcessDefinitionId();\r\n            org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);\r\n            ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId);\r\n\r\n            if (processDefinition.isSuspended()) {\r\n                throw new FlowableException(\"Could not handle signal: process definition with id: \" + processDefinitionId + \" is suspended for \" + eventSubscription);\r\n            }\r\n\r\n            // Start process instance via the flow element linked to the event\r\n            FlowElement flowElement = process.getFlowElement(eventSubscription.getActivityId(), true);\r\n            if (flowElement == null) {\r\n                throw new FlowableException(\"Could not find matching FlowElement for \" + eventSubscription);\r\n            }\r\n\r\n            ProcessInstanceHelper processInstanceHelper = CommandContextUtil.getProcessEngineConfiguration(commandContext).getProcessInstanceHelper();\r\n            processInstanceHelper.createAndStartProcessInstanceWithInitialFlowElement(processDefinition, null, null, null, flowElement, process,\r\n                    getPayloadAsMap(payload), null, null, null, true);\r\n\r\n        } else if (eventSubscription.getScopeId() != null && ScopeTypes.CMMN.equals(eventSubscription.getScopeType())) {\r\n            CommandContextUtil.getProcessEngineConfiguration(commandContext).getCaseInstanceService().handleSignalEvent(eventSubscription, getPayloadAsMap(payload));\r\n        \r\n        } else {\r\n            throw new FlowableException(\"Invalid signal handling: no execution nor process definition set for \" + eventSubscription);\r\n        }\r\n    }\r\n\r\n    protected Map<String, Object> getPayloadAsMap(Object payload) {\r\n        Map<String, Object> variables = null;\r\n        if (payload instanceof Map) {\r\n            variables = (Map<String, Object>) payload;\r","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/event/SignalEventHandler.java#L43-L79","documentation":"When a signal targets a signal start event, SignalEventHandler looks up the flow element in the BPMN model by the subscription's activityId. If the model contains no matching element, this error is thrown, meaning the event subscription points at an element that no longer exists in the deployed process definition.","triggerScenarios":"signalEventReceived/dispatchEvent for a start-event subscription whose activityId is absent from process.getFlowElement(activityId, true) — typically after the definition was changed/redeployed while old subscriptions remained, or a corrupted event subscription row.","commonSituations":"Redeploying an updated BPMN where the signal start event id was renamed/deleted, database restore mismatching ACT_RU_EVENT_SUBSCR with ACT_GE_BYTEARRAY model data, cache staleness after multi-node deployment.","solutions":["Compare the subscription's ACTIVITY_ID_ (ACT_RU_EVENT_SUBSCR) with the signal start event id in the deployed BPMN XML; fix/redeploy the model.","Delete the stale event subscription (runtimeService.deleteEventSubscription / createEventRegistryEventSubscriptionQuery) or cancel the orphaned definition.","Redeploy the original BPMN that contains the referenced start event id.","Restart the node(s) to refresh the process definition cache if the model was just redeployed."],"exampleFix":"// before\n// renamed start signal event id from 'signalStart' to 'signalStart2' in BPMN, subscription stale\n// after\n// keep element ids stable across redeploys, or cleanup:\nfor (EventSubscription sub : runtimeService.createEventSubscriptionQuery()\n        .eventName(\"orderSignal\").list()) {\n    // verify each subscription's activityId exists in the current model before signaling\n}","handlingStrategy":"validation","validationCode":"org.flowable.bpmn.model.Process p = ProcessDefinitionUtil.getProcess(sub.getProcessDefinitionId());\nif (p.getFlowElement(sub.getActivityId(), true) == null) {\n    throw new IllegalStateException(\"Stale subscription: activity \" + sub.getActivityId() + \" not in model\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.signalEventReceived(signalName);\n} catch (FlowableException e) {\n    if (e.getMessage().startsWith(\"Could not find matching FlowElement\")) {\n        cleanupStaleSubscription(signalName);\n    } else { throw e; }\n}","preventionTips":["Never rename or delete signal start event ids across deployments with active subscriptions.","Validate redeployed BPMN against existing event subscriptions.","Restart cluster nodes after model redeploys to avoid stale cache.","Audit ACT_RU_EVENT_SUBSCR after BPMN migrations."],"tags":["flowable","bpmn","signal","missing-flow-element","stale-subscription"],"backgroundTag":"resource-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}