{"record":{"id":"767b5324697e3d1b","repo":"quarkusio/quarkus","slug":"no-datasource-named-datasourcename-exists","errorCode":null,"errorMessage":"No datasource named '<dataSourceName>' exists","messagePattern":"No datasource named '<dataSourceName>' exists","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java","lineNumber":146,"sourceCode":"     */\n    @Deprecated\n    public Set<String> getActiveDataSourceNames() {\n        return AgroalDataSourceUtil.activeDataSourceNames();\n    }\n\n    /**\n     * @deprecated Use {@link AgroalDataSourceUtil#dataSourceInstance(String)} instead.\n     */\n    @Deprecated\n    public AgroalDataSource getDataSource(String dataSourceName) {\n        return ClientProxy.unwrap(AgroalDataSourceUtil.dataSourceInstance(dataSourceName).get());\n    }\n\n    @SuppressWarnings(\"resource\")\n    public AgroalDataSource createDataSource(String dataSourceName, boolean otelEnabled,\n            Map<String, String> buildTimeJdbcProperties) {\n        if (!agroalDataSourceSupport.entries.containsKey(dataSourceName)) {\n            throw new IllegalArgumentException(\"No datasource named '\" + dataSourceName + \"' exists\");\n        }\n\n        DataSourceJdbcBuildTimeConfig dataSourceJdbcBuildTimeConfig = dataSourcesJdbcBuildTimeConfig\n                .dataSources().get(dataSourceName).jdbc();\n        DataSourceRuntimeConfig dataSourceRuntimeConfig = dataSourcesRuntimeConfig.dataSources().get(dataSourceName);\n\n        DataSourceJdbcRuntimeConfig dataSourceJdbcRuntimeConfig = dataSourcesJdbcRuntimeConfig\n                .dataSources().get(dataSourceName).jdbc();\n        if (!dataSourceJdbcRuntimeConfig.url().isPresent()) {\n            throw new IllegalArgumentException(\n                    \"Datasource \" + dataSourceName + \" does not have a JDBC URL and should not be created\");\n        }\n\n        // we first make sure that all available JDBC drivers are loaded in the current TCCL\n        loadDriversInTCCL();\n\n        AgroalDataSourceSupport.Entry matchingSupportEntry = agroalDataSourceSupport.entries.get(dataSourceName);\n        String resolvedDriverClass = matchingSupportEntry.resolvedDriverClass;","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSources.java#L128-L164","documentation":"DataSources.createDataSource() initializes datasources at runtime from the build-time registered entries in agroalDataSourceSupport. Requesting a datasource name that was not defined/registered at build time throws this IllegalArgumentException immediately.","triggerScenarios":"createDataSource(dataSourceName, otelEnabled, buildTimeJdbcProperties) is called (from apply) and !agroalDataSourceSupport.entries.containsKey(dataSourceName) — i.e. the named datasource was never configured at build time.","commonSituations":"@AgroalDataSource or code requesting a datasource whose quarkus.datasource.<name>.* properties were never set; renaming a datasource in config while startup code still uses the old name; typo in the datasource name at the injection/lookup site.","solutions":["Define the datasource in configuration (quarkus.datasource.<name>.db-kind=... plus URL/credentials) so it is registered at build time.","Fix the datasource name used at the lookup/injection site to match a configured datasource.","Verify the config profile (e.g. %prod) actually defines the datasource for the active runtime profile."],"exampleFix":"// before\n@Inject @DataSourceName(\"inventory\") AgroalDataSource ds; // never configured\n// after\nquarkus.datasource.inventory.db-kind=postgresql\nquarkus.datasource.inventory.jdbc.url=jdbc:postgresql://localhost:5432/inventory\n// and/or use an existing name:\n@Inject @DataSourceName(\"inventory\") AgroalDataSource ds;","handlingStrategy":"validation","validationCode":"String name = \"inventory\";\nif (ConfigProvider.getConfig().getOptionalValue(\"quarkus.datasource.\" + name + \".db-kind\", String.class).isEmpty()) {\n    throw new IllegalStateException(\"Datasource '\" + name + \"' is not configured at build time\");\n}","typeGuard":null,"tryCatchPattern":"try { ds = dataSources.createDataSource(name, false, Map.of()); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"No datasource named\")) { log.error(\"Datasource not defined in config: \" + name); } throw e; }","preventionTips":["Define every datasource name used in code in application.properties with at least db-kind and jdbc.url.","Check active profile (%prod, %dev) actually defines the named datasource.","Inject datasources via @Inject @DataSourceId/... instead of hardcoding names where possible."],"tags":["quarkus","agroal","datasource","runtime","configuration"],"backgroundTag":"datasource-not-defined","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}