{"record":{"id":"1c8e09566724a8fd","repo":"flowable/flowable-engine","slug":"cannot-get-process-model-no-current-command-conte","errorCode":null,"errorMessage":"Cannot get process model: no current command context is active","messagePattern":"Cannot get process model: no current command context is active","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessDefinitionUtil.java","lineNumber":83,"sourceCode":"    }\n\n    public static ProcessDefinition getProcessDefinition(String processDefinitionId, boolean checkCacheOnly, ProcessEngineConfigurationImpl processEngineConfiguration) {\n        if (checkCacheOnly) {\n            ProcessDefinitionCacheEntry cacheEntry = processEngineConfiguration.getProcessDefinitionCache().get(processDefinitionId);\n            if (cacheEntry != null) {\n                return cacheEntry.getProcessDefinition();\n            }\n            return null;\n\n        } else {\n            // This will check the cache in the findDeployedProcessDefinitionById method\n            return processEngineConfiguration.getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);\n        }\n    }\n\n    public static Process getProcess(String processDefinitionId) {\n        if (Context.getCommandContext() == null) {\n            throw new FlowableException(\"Cannot get process model: no current command context is active\");\n            \n        } else if (CommandContextUtil.getProcessEngineConfiguration() == null) {\n            return Flowable5Util.getFlowable5CompatibilityHandler().getProcessDefinitionProcessObject(processDefinitionId);\n\n        } else {\n            DeploymentManager deploymentManager = CommandContextUtil.getProcessEngineConfiguration().getDeploymentManager();\n\n            // This will check the cache in the findDeployedProcessDefinitionById and resolveProcessDefinition method\n            ProcessDefinition processDefinitionEntity = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);\n            return deploymentManager.resolveProcessDefinition(processDefinitionEntity).getProcess();\n        }\n    }\n\n    public static BpmnModel getBpmnModel(String processDefinitionId) {\n        if (CommandContextUtil.getProcessEngineConfiguration() == null) {\n            return Flowable5Util.getFlowable5CompatibilityHandler().getProcessDefinitionBpmnModel(processDefinitionId);\n\n        } else {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/util/ProcessDefinitionUtil.java#L65-L101","documentation":"The process model for a process definition is resolved through the command context. ProcessDefinitionUtil.getProcess requires an active CommandContext (set up by engine services/commands); when Context.getCommandContext() is null it cannot access engine internals and throws this FlowableException. It typically means the method is being called outside an engine command/transaction.","triggerScenarios":"Calling getProcess(processDefinitionId) from non-command code such as a plain thread, a servlet filter, an application startup hook, or test code that has not wrapped the call in a command (e.g. managementService.executeCommand or an engine service call).","commonSituations":"Custom extensions calling internal util classes directly instead of going through engine services; asynchronous jobs or scheduled threads without command context propagation; unit tests invoking engine internals without CommandContextUtil initialization.","solutions":["Run the logic inside a command: processEngineConfiguration.getCommandExecutor().execute(new Command<Process>() { ... }) or managementService.executeCommand(...).","Call public engine services (RepositoryService / RuntimeService) instead of internal ProcessDefinitionUtil to let the engine establish the command context.","If in a custom async thread, propagate the CommandContext explicitly using Context/CommandContextUtil within a command wrapper.","In tests, use the engine's command executor helper rather than static util access."],"exampleFix":"// before\nProcess process = ProcessDefinitionUtil.getProcess(processDefinitionId); // no context\n\n// after\nProcess process = processEngine.getManagementService().executeCommand(\n    commandContext -> ProcessDefinitionUtil.getProcess(processDefinitionId));","handlingStrategy":"try-catch","validationCode":"// verify a command context is active before calling internals\nif (Context.getCommandContext() == null) {\n    // route through the engine instead of calling the util directly\n}","typeGuard":null,"tryCatchPattern":"try {\n    Process p = managementService.executeCommand(\n        ctx -> ProcessDefinitionUtil.getProcess(processDefinitionId));\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"no current command context\")) {\n        throw new IllegalStateException(\"Wrap internal calls in a command\", e);\n    }\n    throw e;\n}","preventionTips":["Never call engine internal util classes from raw threads; use command executor","Prefer public RepositoryService/RuntimeService APIs over internals","In custom async work, always establish a CommandContext via CommandExecutor"],"tags":["command-context","threading","engine-internals"],"backgroundTag":"authentication-required","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"}