[Postgres] [OID] [Quarkus] [rider-cdi] java.lang.ClassCastException: class io.agroal.pool.wrapper.ConnectionWrapper cannot be cast to class org.postgresql.PGConnection
See original GitHub issueUsing rider-cdi
(1.18.0
) in Quarkus, trying to validate test results via @ExpectedDataSet
for a table containing an oid
-typed column I get above exception
java.lang.ClassCastException: class io.agroal.pool.wrapper.ConnectionWrapper cannot be cast to class org.postgresql.PGConnection
Stacktrace
at org.dbunit.ext.postgresql.PostgreSQLOidDataType.getSqlValue(PostgreSQLOidDataType.java:42) at org.dbunit.database.ForwardOnlyResultSetTable.getValue(ForwardOnlyResultSetTable.java:104) at org.dbunit.dataset.DefaultTable.addTableRows(DefaultTable.java:139) at org.dbunit.database.CachedResultSetTable.<init>(CachedResultSetTable.java:69) at org.dbunit.database.CachedResultSetTableFactory.createTable(CachedResultSetTableFactory.java:61) at org.dbunit.database.DatabaseDataSet.getTable(DatabaseDataSet.java:338) at com.github.database.rider.core.dataset.DataSetExecutorImpl.compareCurrentDataSetWith(DataSetExecutorImpl.java:1004) at com.github.database.rider.core.dataset.DataSetExecutorImpl.compareCurrentDataSetWith(DataSetExecutorImpl.java:1062) at com.github.database.rider.core.dataset.DataSetExecutorImpl.compareCurrentDataSetWith(DataSetExecutorImpl.java:1057) at com.github.database.rider.cdi.DataSetProcessor.compareCurrentDataSetWith(DataSetProcessor.java:155)
Reason
PostgreSQLOidDataType
gets a Agroal
-wrapped connection and cast fails
Suggestion
Could you unwrap the connection prior to passing it to DBUnit, maybe in https://github.com/database-rider/database-rider/blob/06f738fdfe6ab7f2d5a6711c1115c5e5672025f0/rider-core/src/main/java/com/github/database/rider/core/connection/RiderDataSource.java#L84?
Also
Possibly related to #111
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Re: Cast java.sql.Connection to PGConnection - PostgreSQL
Caused by: java.lang.ClassCastException: >> org.apache.tomcat.dbcp.dbcp2.PoolingDataSource$PoolGuardConnectionWrapper >> cannot be cast to ...
Read more >Reactive SQL Clients - Quarkus
Currently, the following database servers are supported: IBM Db2. PostgreSQL. MariaDB/MySQL. Microsoft SQL Server. Oracle ...
Read more >Cast java.sql.Connection to PGConnection - Stack Overflow
if (dataSource.getConnection().isWrapperFor(PGConnection.class)) { PGConnection pgConnection = dataSource.
Read more >Quarkus build fails because it can't connect to the DB
at org.postgresql.Driver.connect(Driver.java:264). at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:204).
Read more >Thread: Cast java.sql.Connection to PGConnection
lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to org.postgresql.PGConnection ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, thanks for checking!
1.21.1
should be at maven central in next hours.Thank you again!
Hi @rmpestano, thanks for the quick fix - i tried it in both reproducer and real projects and both now work OK with regards to the issue. When do you plan to release the fix?