{"record":{"id":"26fd6020aec8fc57","repo":"flowable/flowable-engine","slug":"couldn-t-get-db-schema-version-26fd60","errorCode":null,"errorMessage":"couldn't get db schema version","messagePattern":"couldn't get db schema version","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSession.java","lineNumber":953,"sourceCode":"            }\n            if (dbSqlSessionFactory.isDbHistoryUsed() && !isHistoryTablePresent()) {\n                errorMessage = addMissingComponent(errorMessage, \"history\");\n            }\n\n            if (errorMessage != null) {\n                throw new ActivitiException(\"Activiti database problem: \" + errorMessage);\n            }\n\n        } catch (Exception e) {\n            if (isMissingTablesException(e)) {\n                throw new ActivitiException(\n                        \"no activiti tables in db. set <property name=\\\"databaseSchemaUpdate\\\" to value=\\\"true\\\" or value=\\\"create-drop\\\" (use create-drop for testing only!) in bean processEngineConfiguration in flowable.cfg.xml for automatic schema creation\",\n                        e);\n            } else {\n                if (e instanceof RuntimeException) {\n                    throw (RuntimeException) e;\n                } else {\n                    throw new ActivitiException(\"couldn't get db schema version\", e);\n                }\n            }\n        }\n\n        LOGGER.debug(\"activiti db schema check successful\");\n    }\n\n    protected String addMissingComponent(String missingComponents, String component) {\n        if (missingComponents == null) {\n            return \"Tables missing for component(s) \" + component;\n        }\n        return missingComponents + \", \" + component;\n    }\n\n    protected String getDbVersion() {\n        String selectSchemaVersionStatement = dbSqlSessionFactory.mapStatement(\"selectDbSchemaVersion\");\n        return (String) sqlSession.selectOne(selectSchemaVersionStatement);\n    }","sourceCodeStart":935,"sourceCodeEnd":971,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSession.java#L935-L971","documentation":"The final fallback in dbSchemaCheckVersion(): if the caught exception during the schema check is neither a missing-tables error nor a RuntimeException, it is wrapped in this ActivitiException ('couldn't get db schema version') with the original as cause. It means the version check failed for an unexpected reason — typically connectivity or driver issues — rather than missing tables.","triggerScenarios":"getDbVersion() or table-presence checks throw a checked/non-runtime exception, e.g. SQLException wrapped as non-runtime, driver class issues, connection failures, or catalog/permission problems that don't match the missing-tables signature.","commonSituations":"Database unreachable or credentials wrong at engine bootstrap; missing/incorrect JDBC driver on the classpath; network/firewall drops; DB user lacking permission to query ACT_GE_PROPERTY.","solutions":["Inspect the wrapped cause (e.getCause()) for the real failure — usually a SQLException with connection/permission details.","Verify the JDBC URL, credentials, and that the database is reachable (test with a plain SQL client from the same host).","Confirm the correct JDBC driver jar is on the classpath and matches the DB server version.","Grant the DB user rights to read the ACT_GE_PROPERTY table (or create the schema if it doesn't exist via databaseSchemaUpdate=true)."],"exampleFix":"// before: wrong credentials, cause hidden\n<property name=\"jdbcUrl\" value=\"jdbc:h2:tcp://localhost/act\"/>\n<property name=\"jdbcPassword\" value=\"wrong\"/>\n\n// after: fix creds; check cause via logs\n<property name=\"jdbcPassword\" value=\"sa\"/>\nlog.debug(\"schema check failed\", e.getCause());","handlingStrategy":"try-catch","validationCode":"// Verify DB connectivity before engine bootstrap\ntry (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {\n    if (!c.isValid(5)) throw new IllegalStateException(\"Cannot connect to database\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ProcessEngines.buildProcessEngine();\n} catch (ActivitiException e) {\n    if (\"couldn't get db schema version\".equals(e.getMessage()) && e.getCause() != null) {\n        log.error(\"Schema check failed: {}\", e.getCause().getMessage(), e.getCause());\n    }\n    throw e;\n}","preventionTips":["Always inspect the cause chain of this wrapper — the root SQLException names the real problem.","Pre-flight DB connectivity and credentials in deployment scripts before engine startup.","Ensure the JDBC driver jar is on the classpath and compatible with the DB server version."],"tags":["database","schema","connectivity","bootstrap"],"backgroundTag":"database-query-failed","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"}