flowable/flowable-engine · warning · FlowableException

Unable to close the local ProcessEngine

Error message

Unable to close the local ProcessEngine

What it means

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'.

Source

Thrown at modules/flowable-cdi/src/main/java/org/flowable/cdi/impl/LocalProcessEngineLookup.java:56

    @Override
    public ProcessEngine getProcessEngine() {
        return ProcessEngines.getProcessEngine(getProcessEngineName());
    }

    public String getProcessEngineName() {
        return processEngineName;
    }

    public void setProcessEngineName(String processEngineName) {
        this.processEngineName = processEngineName;
    }

    @Override
    public void ungetProcessEngine() {
        try {
            ProcessEngines.getProcessEngine(getProcessEngineName()).close();
        } catch (Exception e) {
            throw new FlowableException("Unable to close the local ProcessEngine", e);
        }
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Inspect the wrapped cause (e) — fix the underlying close failure (DB connectivity, job executor shutdown).
  2. Ensure the job executor is enabled/shut down properly; set asyncExecutorActivate appropriately or stop it before close.
  3. Check that nothing else closed the engine first, avoiding double-close.
  4. If shutdown-order noise is acceptable, catch/log this at application teardown since the app is stopping anyway.

Example fix

// before
ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
    .setJobExecutorActivate(true) // threads may block close
    .buildProcessEngine();
// after
ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration()
    .setAsyncExecutorActivate(true) // properly managed executor lifecycle
    .buildProcessEngine();
// and on shutdown:
try { ProcessEngines.getDefaultProcessEngine().close(); } catch (Exception e) { log.warn(..., e); }
Defensive patterns

Strategy: try-catch

Validate before calling

ProcessEngine engine = ProcessEngines.getProcessEngine(name);
if (engine != null && !engine.isClosed()) { /* proceed to close */ }

Try / catch

try {
  lookup.ungetProcessEngine();
} catch (FlowableException e) {
  logger.warn("ProcessEngine close failed during shutdown", e.getCause());
}

Prevention

When it happens

Trigger: 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.

Common situations: Database unreachable during application shutdown; H2 in-memory setups dropping connections; custom configuration leaving non-daemon job-executor threads that block clean close.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/e97d86e4d6d020dc. Report an issue: GitHub.