{"record":{"id":"b04c774d4e9de0b1","repo":"flowable/flowable-engine","slug":"invalid-dbsqlsession-no-active-connection-found","errorCode":null,"errorMessage":"Invalid dbSqlSession: no active connection found","messagePattern":"Invalid dbSqlSession: no active connection found","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSessionFactory.java","lineNumber":99,"sourceCode":"    @Override\n    public Session openSession(CommandContext commandContext) {\n        DbSqlSession dbSqlSession = createDbSqlSession();\n        if (getDatabaseSchema() != null && getDatabaseSchema().length() > 0) {\n            try {\n                dbSqlSession.getSqlSession().getConnection().setSchema(getDatabaseSchema());\n            } catch (SQLException e) {\n                throw new FlowableException(\"Could not set database schema on connection\", e);\n            }\n        }\n        if (getDatabaseCatalog() != null && getDatabaseCatalog().length() > 0) {\n            try {\n                dbSqlSession.getSqlSession().getConnection().setCatalog(getDatabaseCatalog());\n            } catch (SQLException e) {\n                throw new FlowableException(\"Could not set database catalog on connection\", e);\n            }\n        }\n        if (dbSqlSession.getSqlSession().getConnection() == null) {\n            throw new FlowableException(\"Invalid dbSqlSession: no active connection found\");\n        }\n        return dbSqlSession;\n    }\n\n    protected DbSqlSession createDbSqlSession() {\n        return new DbSqlSession(this, Context.getCommandContext().getSession(EntityCache.class));\n    }\n\n    // insert, update and delete statements\n    // /////////////////////////////////////\n\n    public String getInsertStatement(Entity object) {\n        return getStatement(object.getClass(), insertStatements, \"insert\");\n    }\n\n    public String getInsertStatement(Class<? extends Entity> clazz) {\n        return getStatement(clazz, insertStatements, \"insert\");\n    }","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSessionFactory.java#L81-L117","documentation":"Session opening failure in the DbSqlSessionFactory: the newly created DbSqlSession has no active JDBC connection (connection retrieval produced none), so schema/catalog setup and SQL execution cannot proceed.","triggerScenarios":"The MyBatis SqlSession/transaction has no active Connection — typically a misconfigured datasource/transaction factory, or connection retrieval returning null in a custom environment.","commonSituations":"Custom CommandContext/transaction interceptor that fails to attach the connection; misconfigured Spring/standalone datasource; connection closed by the pool before session use.","solutions":["Verify the datasource and transaction factory are correctly wired into the process/engine configuration.","Ensure a transaction/connection is active for the command (correct command context interceptor setup).","Check pool settings so connections aren't closed/recycled mid-command.","Run with debug logging on transaction management to see when the connection is lost."],"exampleFix":"// before\n<property name=\"dataSource\" ref=\"undefinedDataSource\" />\n// after\n<bean id=\"dataSource\" class=\"org.apache.commons.dbcp2.BasicDataSource\">\n  <property name=\"url\" value=\"jdbc:h2:mem:flowable\" />\n  <property name=\"username\" value=\"sa\" />\n</bean>","handlingStrategy":"validation","validationCode":"try (Connection c = dataSource.getConnection()) {\n  ResultSet rs = c.getMetaData().getCatalogs();\n  boolean found = false;\n  while (rs.next()) { if (catalog.equalsIgnoreCase(rs.getString(\"TABLE_CAT\"))) found = true; }\n  if (!found) throw new IllegalStateException(\"Catalog not found: \" + catalog);\n  c.setCatalog(catalog);\n}","typeGuard":null,"tryCatchPattern":"try { engineConfiguration.buildProcessEngine(); }\ncatch (FlowableException e) {\n  if (e.getMessage().contains(\"set database catalog\")) { /* verify catalog or encode it in the JDBC URL */ }\n  throw e;\n}","preventionTips":["Confirm the catalog/database exists before startup.","Encode the database in the JDBC URL instead of setCatalog when possible.","Keep JDBC drivers up to date.","Validate configuration values in a smoke test before deploying."],"tags":["database","jdbc","connection","configuration"],"backgroundTag":"connection-refused","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"}