{"record":{"id":"e97d86e4d6d020dc","repo":"flowable/flowable-engine","slug":"unable-to-close-the-local-processengine","errorCode":null,"errorMessage":"Unable to close the local ProcessEngine","messagePattern":"Unable to close the local ProcessEngine","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"warning","filePath":"modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/LocalProcessEngineLookup.java","lineNumber":56,"sourceCode":"    @Override\r\n    public ProcessEngine getProcessEngine() {\r\n        return ProcessEngines.getProcessEngine(getProcessEngineName());\r\n    }\r\n\r\n    public String getProcessEngineName() {\r\n        return processEngineName;\r\n    }\r\n\r\n    public void setProcessEngineName(String processEngineName) {\r\n        this.processEngineName = processEngineName;\r\n    }\r\n\r\n    @Override\r\n    public void ungetProcessEngine() {\r\n        try {\r\n            ProcessEngines.getProcessEngine(getProcessEngineName()).close();\r\n        } catch (Exception e) {\r\n            throw new FlowableException(\"Unable to close the local ProcessEngine\", e);\r\n        }\r\n    }\r\n}\r\n","sourceCodeStart":38,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/LocalProcessEngineLookup.java#L38-L60","documentation":"LocalProcessEngineLookup.ungetProcessEngine() closes the engine it created at container shutdown; if ProcessEngines.getProcessEngine(name).close() throws for any reason, the exception is wrapped in a FlowableException 'Unable to close the local ProcessEngine'.","triggerScenarios":"Engine close fails during shutdown — e.g. job executor threads not stopping, database connections cannot be released (pool/connection issues), or the engine was already closed elsewhere.","commonSituations":"Database unreachable during application shutdown; H2 in-memory setups dropping connections; custom configuration leaving non-daemon job-executor threads that block clean close.","solutions":["Inspect the wrapped cause (e) — fix the underlying close failure (DB connectivity, job executor shutdown).","Ensure the job executor is enabled/shut down properly; set asyncExecutorActivate appropriately or stop it before close.","Check that nothing else closed the engine first, avoiding double-close.","If shutdown-order noise is acceptable, catch/log this at application teardown since the app is stopping anyway."],"exampleFix":"// before\nProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()\n    .setJobExecutorActivate(true) // threads may block close\n    .buildProcessEngine();\n// after\nProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()\n    .setAsyncExecutorActivate(true) // properly managed executor lifecycle\n    .buildProcessEngine();\n// and on shutdown:\ntry { ProcessEngines.getDefaultProcessEngine().close(); } catch (Exception e) { log.warn(..., e); }","handlingStrategy":"try-catch","validationCode":"ProcessEngine engine = ProcessEngines.getProcessEngine(name);\nif (engine != null && !engine.isClosed()) { /* proceed to close */ }","typeGuard":null,"tryCatchPattern":"try {\n  lookup.ungetProcessEngine();\n} catch (FlowableException e) {\n  logger.warn(\"ProcessEngine close failed during shutdown\", e.getCause());\n}","preventionTips":["Inspect the cause to fix DB/job-executor shutdown issues","Stop async executor before closing the engine","Avoid double-closing engines","Treat shutdown-time close failures as non-fatal cleanup noise"],"tags":["flowable","cdi","shutdown","process-engine","cleanup"],"backgroundTag":"internal-invariant-violation","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"}