{"record":{"id":"3031a9d70bdbdb81","repo":"flowable/flowable-engine","slug":"no-event-definition-found-for-id","errorCode":null,"errorMessage":"No event definition found for id = ''","messagePattern":"No event definition found for id = ''","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/GetEventModelCmd.java","lineNumber":68,"sourceCode":"    public GetEventModelCmd(String eventDefinitionKey, String tenantId, String parentDeploymentId) {\n        this(eventDefinitionKey, null);\n        this.parentDeploymentId = parentDeploymentId;\n        this.tenantId = tenantId;\n    }\n\n    @Override\n    public EventModel execute(CommandContext commandContext) {\n        EventRegistryEngineConfiguration eventEngineConfiguration = CommandContextUtil.getEventRegistryConfiguration(commandContext);\n        EventDeploymentManager deploymentManager = eventEngineConfiguration.getDeploymentManager();\n        EventDefinitionEntityManager eventDefinitionEntityManager = eventEngineConfiguration.getEventDefinitionEntityManager();\n\n        // Find the event definition\n        EventDefinitionEntity eventDefinitionEntity = null;\n        if (eventDefinitionId != null) {\n\n            eventDefinitionEntity = deploymentManager.findDeployedEventDefinitionById(eventDefinitionId);\n            if (eventDefinitionEntity == null) {\n                throw new FlowableObjectNotFoundException(\"No event definition found for id = '\" + eventDefinitionId + \"'\", EventDefinitionEntity.class);\n            }\n\n        } else if (eventDefinitionKey != null && (tenantId == null || EventRegistryEngineConfiguration.NO_TENANT_ID.equals(tenantId)) && \n                        (parentDeploymentId == null || eventEngineConfiguration.isAlwaysLookupLatestDefinitionVersion())) {\n\n            eventDefinitionEntity = deploymentManager.findDeployedLatestEventDefinitionByKey(eventDefinitionKey);\n            if (eventDefinitionEntity == null) {\n                throw new FlowableObjectNotFoundException(\"No event definition found for key '\" + eventDefinitionKey + \"'\", EventDefinitionEntity.class);\n            }\n\n        } else if (eventDefinitionKey != null && tenantId != null && !EventRegistryEngineConfiguration.NO_TENANT_ID.equals(tenantId) && \n                        (parentDeploymentId == null || eventEngineConfiguration.isAlwaysLookupLatestDefinitionVersion())) {\n\n            eventDefinitionEntity = eventDefinitionEntityManager.findLatestEventDefinitionByKeyAndTenantId(eventDefinitionKey, tenantId);\n            \n            if (eventDefinitionEntity == null && eventEngineConfiguration.isFallbackToDefaultTenant()) {\n                String defaultTenant = eventEngineConfiguration.getDefaultTenantProvider().getDefaultTenant(tenantId, ScopeTypes.EVENT_REGISTRY, eventDefinitionKey);\n                if (StringUtils.isNotEmpty(defaultTenant)) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/cmd/GetEventModelCmd.java#L50-L86","documentation":"GetEventModelCmd resolves an EventDefinitionEntity and returns its EventModel. When eventDefinitionId is provided but no deployed event definition with that id exists, deploymentManager.findDeployedEventDefinitionById returns null and the command throws FlowableObjectNotFoundException including the id.","triggerScenarios":"Executing GetEventModelCmd with an eventDefinitionId that was never deployed, was deleted by a redeploy/cleanup, or belongs to a different event-registry database/tenant.","commonSituations":"Hard-coded ids from another environment; stale cache of ids after deployment deletion; using a process definition id with the event registry; DB not migrated (missing event definition rows).","solutions":["Look up valid ids via EventRepositoryService.createEventDefinitionQuery().list() and use one of those","Redeploy the event definition if it was removed","Check you are connected to the same database/engine where the definition was deployed"],"exampleFix":"// before\nEventModel model = eventRepositoryService.getEventModelById(staleId);\n// after\nEventDefinition def = eventRepositoryService.createEventDefinitionQuery()\n    .eventDefinitionId(eventDefinitionId).singleResult();\nif (def == null) {\n    eventRepositoryService.createDeployment().addClasspathResource(\"order.event.json\").deploy();\n}\nEventModel model = eventRepositoryService.getEventModelById(eventDefinitionId);","handlingStrategy":"try-catch","validationCode":"EventDefinition def = eventRepositoryService.createEventDefinitionQuery().eventDefinitionId(id).singleResult();\nif (def == null) throw new IllegalArgumentException(\"No event definition: \" + id);","typeGuard":"boolean eventDefinitionExists = eventRepositoryService.createEventDefinitionQuery().eventDefinitionId(id).count() > 0;","tryCatchPattern":"try {\n    return eventRepositoryService.getEventModelById(id);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Event definition {} missing; redeploying\", id);\n    redeployEventModels();\n    return eventRepositoryService.getEventModelById(id);\n}","preventionTips":["Resolve ids dynamically from queries, never hard-code across environments","Re-deploy event models as part of application startup if they can be deleted","Confirm you are on the same database as the deployment"],"tags":["flowable","event-registry","not-found","event-definition"],"backgroundTag":"entity-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"}