{"record":{"id":"cfff74fb68704af7","repo":"quarkusio/quarkus","slug":"a-datasource-was-configured-as-connection-pool-bu","errorCode":null,"errorMessage":"A Datasource was configured as Connection Pool, but it's not the Agroal connection pool. In Quarkus, you need to use Agroal.","messagePattern":"A Datasource was configured as Connection Pool, but it's not the Agroal connection pool\\. In Quarkus, you need to use Agroal\\.","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusConnectionProviderInitiator.java","lineNumber":41,"sourceCode":"    }\n\n    @Override\n    public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {\n        //First, check that this setup won't need to deal with multi-tenancy at the connection pool level:\n        final MultiTenancyStrategy strategy = MultiTenancyStrategy.determineMultiTenancyStrategy(configurationValues);\n        if (strategy == MultiTenancyStrategy.DATABASE || strategy == MultiTenancyStrategy.SCHEMA) {\n            // nothing to do, but given the separate hierarchies have to handle this here.\n            return null;\n        }\n\n        //Next, we'll want to try the Quarkus optimised pool:\n        Object o = configurationValues.get(AvailableSettings.DATASOURCE);\n        if (o != null) {\n            final AgroalDataSource ds;\n            try {\n                ds = (AgroalDataSource) o;\n            } catch (ClassCastException cce) {\n                throw new HibernateException(\n                        \"A Datasource was configured as Connection Pool, but it's not the Agroal connection pool. In Quarkus, you need to use Agroal.\");\n            }\n            return new QuarkusConnectionProvider(ds);\n        }\n\n        //When not using the Quarkus specific Datasource, delegate to traditional bootstrap so to not break\n        //applications using persistence.xml :\n        return ConnectionProviderInitiator.INSTANCE.initiateService(configurationValues, registry);\n    }\n\n}\n","sourceCodeStart":23,"sourceCodeEnd":53,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusConnectionProviderInitiator.java#L23-L53","documentation":"QuarkusConnectionProviderInitiator installs Hibernate's connection provider. When Hibernate is configured with a datasource (AvailableSettings.DATASOURCE), Quarkus requires that object to be an AgroalDataSource; a cast to AgroalDataSource failing triggers this HibernateException, since Quarkus routes all JDBC pooling through Agroal.","triggerScenarios":"Setting hibernate.connection.datasource (or the equivalent quarkus property / persistence.xml datasource JNDI setting) to a DataSource that is not Agroal's implementation — e.g. a HikariDataSource, a custom DataSource, or a wrapped/proxied DataSource — while bootstrapping the persistence unit.","commonSituations":"Porting Spring Boot/Hikari configurations into Quarkus; registering a custom DataSource bean and handing it to Hibernate; wrapping AgroalDataSource in a delegating tracing/metrics proxy that breaks the cast; mixing persistence.xml datasource references with Quarkus-managed datasources.","solutions":["Remove custom datasource wiring and use Quarkus' Agroal datasource config (quarkus.datasource.*), referenced via quarkus.hibernate-orm.datasource.","If you need a custom pool, configure Agroal instead (quarkus.datasource.jdbc.*) — do not inject Hikari or another pool.","If you wrap AgroalDataSource, unwrap to the underlying AgroalDataSource before assigning it as Hibernate's DATASOURCE property."],"exampleFix":"// before\nHikariDataSource ds = new HikariDataSource(cfg);\nproperties.put(AvailableSettings.DATASOURCE, ds);\n\n// after (application.properties)\nquarkus.datasource.db-kind=postgresql\nquarkus.datasource.username=...\nquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/db","handlingStrategy":"type-guard","validationCode":"Object o = properties.get(AvailableSettings.DATASOURCE);\nif (o != null && !(o instanceof AgroalDataSource)) {\n    throw new IllegalStateException(\"Hibernate DATASOURCE must be an AgroalDataSource, got: \"\n        + o.getClass().getName());\n}","typeGuard":"boolean isAgroal(Object ds) {\n    return ds instanceof AgroalDataSource;\n}","tryCatchPattern":"try {\n    sf = factory.buildSessionFactory();\n} catch (HibernateException e) {\n    if (e.getMessage().contains(\"not the Agroal connection pool\")) {\n        log.error(\"Configure Hibernate to use the Quarkus Agroal datasource (quarkus.datasource.*), not a custom pool\");\n    }\n    throw e;\n}","preventionTips":["Always use quarkus.datasource.* config and let Quarkus wire Agroal to Hibernate","Never assign Hikari/other pool DataSources to Hibernate's DATASOURCE property","If wrapping AgroalDataSource, unwrap before handing it to Hibernate","Do not mix persistence.xml datasource references with Quarkus datasources"],"tags":["hibernate-orm","agroal","datasource","connection-pool","jdbc"],"backgroundTag":"unsupported-connection-pool","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}