{"record":{"id":"6ef294be1b76a3d1","repo":"flowable/flowable-engine","slug":"process-model-id-processdefinitionid-could","errorCode":null,"errorMessage":"Process model (id = ${processDefinitionId}) could not be found for ${execution}","messagePattern":"Process model \\(id = (.+?)\\) could not be found for (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java","lineNumber":84,"sourceCode":"\r\n        CommandContext commandContext = Context.getCommandContext();\r\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\r\n        EventSubscriptionService eventSubscriptionService = processEngineConfiguration.getEventSubscriptionServiceConfiguration().getEventSubscriptionService();\r\n\r\n        List<CompensateEventSubscriptionEntity> eventSubscriptions = new ArrayList<>();\r\n        if (StringUtils.isNotEmpty(activityRef)) {\r\n            \r\n            // If an activity ref is provided, only that activity is compensated\r\n            List<CompensateEventSubscriptionEntity> compensationEvents = eventSubscriptionService\r\n                    .findCompensateEventSubscriptionsByProcessInstanceIdAndActivityId(execution.getProcessInstanceId(), activityRef);\r\n            \r\n            if (compensationEvents == null || compensationEvents.size() == 0) {\r\n                // check if compensation activity was referenced directly (backwards compatibility pre 6.4.0)\r\n                \r\n                String processDefinitionId = execution.getProcessDefinitionId();\r\n                Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);\r\n                if (process == null) {\r\n                    throw new FlowableException(\"Process model (id = \" + processDefinitionId + \") could not be found for \" + execution);\r\n                }\r\n\r\n                String compensationActivityId = null;\r\n                FlowElement flowElement = process.getFlowElement(activityRef, true);\r\n                if (flowElement instanceof Activity activity) {\r\n                    if (activity.isForCompensation()) {\r\n                        List<Association> associations = process.findAssociationsWithTargetRefRecursive(activity.getId());\r\n                        for (Association association : associations) {\r\n                            FlowElement sourceElement = process.getFlowElement(association.getSourceRef(), true);\r\n                            if (sourceElement instanceof BoundaryEvent sourceBoundaryEvent) {\r\n                                if (sourceBoundaryEvent.getAttachedToRefId() != null) {\r\n                                    compensationActivityId = sourceBoundaryEvent.getAttachedToRefId();\r\n                                    break;\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n                }\r","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/behavior/IntermediateThrowCompensationEventActivityBehavior.java#L66-L102","documentation":"Thrown by IntermediateThrowCompensationEventActivityBehavior when an intermediate throwing compensation event executes and ProcessDefinitionUtil.getProcess(processDefinitionId) returns null for the execution's process definition id. It means the BPMN process model for the running execution cannot be resolved from the process definition cache/repository, so the behavior cannot look up the referenced compensation activity element.","triggerScenarios":"Executing an intermediate throw compensation event (optionally with an activityRef for pre-6.4.0 backwards compatibility) when the process definition for execution.getProcessDefinitionId() is no longer resolvable, e.g. the deployment/definition was deleted while an execution was still running.","commonSituations":"Cascade-delete of deployments or process definitions while process instances are in flight; stale process definition cache after redeploying with a new deployment that removed old definitions; database restored/purged while long-running executions still reference old definitions; misconfigured process definition cache in cluster setups.","solutions":["Check that the deployment and process definition backing the running execution still exist (ACT_RE_PROCDEF / repositoryService.createProcessDefinitionQuery().processDefinitionId(id)) before or while the compensation event fires.","Stop deleting deployments/process definitions that have active process instances; migrate or complete those instances first.","Redeploy the process model so the definition is present in the repository and definition cache.","Restart the engine/clear the definition cache so it reloads definitions from the repository after a database restore.","If instances are unrecoverable, delete the stale process instances referencing the missing definition."],"exampleFix":"// before: deleting the deployment while instances run\nrepositoryService.deleteDeployment(deploymentId, true);\n// after: verify no running instances for definitions in the deployment first\nlong running = repositoryService.createProcessDefinitionQuery()\n    .deploymentId(deploymentId)\n    .list().stream()\n    .mapToLong(pd -> runtimeService.createProcessInstanceQuery()\n        .processDefinitionId(pd.getId()).count())\n    .sum();\nif (running == 0) {\n    repositoryService.deleteDeployment(deploymentId, true);\n}","handlingStrategy":"validation","validationCode":"ProcessDefinition pd = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionId(execution.getProcessDefinitionId()).singleResult();\nif (pd == null) {\n    throw new IllegalStateException(\"Process definition gone while instance is running: \"\n        + execution.getProcessDefinitionId());\n}","typeGuard":"boolean definitionResolvable(DelegateExecution e) {\n    return repositoryService.createProcessDefinitionQuery()\n        .processDefinitionId(e.getProcessDefinitionId()).count() > 0;\n}","tryCatchPattern":"try {\n    process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());\n} catch (FlowableException ex) {\n    logger.error(\"Process model missing for {}\", execution.getProcessDefinitionId(), ex);\n    throw ex;\n}","preventionTips":["Never delete deployments with active process instances; check runtimeService.createProcessInstanceQuery().processDefinitionId(id).count() first.","Keep definition cache consistent across cluster nodes (shared DB, same engine config).","Restore DB and engine state together; never point a live engine at a purged repository.","Document a migration path for long-running instances before redeploying changed models."],"tags":["bpmn","compensation","process-definition","flowable"],"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-14T05:17:10.506Z"}