No suitable driver found for Postgresql with TestContainers since Quarkus 1.8
See original GitHub issueDescribe the bug
I have a TestContainers test that pings a Postgres DB. This test does not actually use Quarkus but I realized that it was working in 1.7.3 and failing in 1.8.
It is not a stopper for me (as I said, I realized I should have taken the @QuarkusTest
annotation) but it sounds that something has been introduced that it makes this test fail (this test has been working since Quarkus 1.6 at least).
Expected behavior
The test should pass as in 1.7.3
Actual behavior
The test fail with:
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:32831/vintageStoreDB?loggerLevel=OFF
at org.acme.PingPostgreSQLTest.shouldPingPostgreSQL(PingPostgreSQLTest.java:32)
To Reproduce
Generate a brand new Quarkus 1.7.3-Final app with the Postgres extension. Then, add the TestContainers dependency:
<properties>
...
<testcontainers.version>1.14.3</testcontainers.version>
</properties>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
Now create a new Test
@QuarkusTest
@Testcontainers
public class PingPostgreSQLTest {
@Container
public static PostgreSQLContainer pg = new PostgreSQLContainer<>("postgres:12.4")
.withDatabaseName("vintageStoreDB")
.withUsername("vintage")
.withPassword("vintage")
.withExposedPorts(5432);
@Test
public void shouldPingPostgreSQL() throws Exception {
pg.start();
try (Connection con = DriverManager.getConnection(pg.getJdbcUrl(), pg.getUsername(), pg.getPassword());
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECT VERSION()")) {
if (rs.next()) {
assertTrue(rs.getString(1).contains("PostgreSQL 12"));
} else {
throw new Exception();
}
}
pg.stop();
}
}
This test just uses TestContainers to ping a Postgres db. It doesn’t use any Quarkus. In fact, if you leave the @QuarkusTest
annotation it also works. Then, move to Quarkus 1.8.0, it fails.
Configuration
The test with 1.7.3 works even without any application.properties
file declaring a Postgres driver or JDBC URL.
Because it is now failing with 1.8 I tried to add quarkus.datasource.db-kind=postgresql
and so on.
Environment (please complete the following information):
- Output of
uname -a
orver
: Darwin iMac-Pro-de-Antonio.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64 - Output of
java -version
: java version “11.0.6” 2020-01-14 LTS - GraalVM version (if different from Java):
- Quarkus version or git rev: 1.8.0-Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): 3.6.3_1
Additional context (Add any other context about the problem here.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Just tested with Quarkus 1.8.2 and its ok now.
Hum… I’ve tried to invoke
DriverManager.getDrivers()
before getting the connection, but it does not work.