quarkus: Reactive Postgres Client and Flyway/Postgres does not work together

Describe the bug The use of the reactive postgres client and flyway or classical agroal datasource together in one project does not work. Its not possible to configure both features at the moment because reactive postgres client must be configured with quarkus.datasource.url=vertx-reactive:postgresql://localhost:5432/quarkus_test and flyway with quarkus.datasource.url=jdbc:postgresql://localhost:5432/quarkus_test (both use the default datasource).

Expected behavior The use of reactive postgres client and flyway/agroal in the same quarkus project should be possible

Actual behavior Exception at startup:

java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl1.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:100)
        at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:130)
        at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:173)
        at io.quarkus.dev.DevModeMain.main(DevModeMain.java:100)
Caused by: java.lang.NullPointerException
        at io.quarkus.agroal.runtime.DataSourceProducer_ProducerMethod_createDefaultDataSource_7c487e3ef869f878aa871e917c94f4d26d5d5c56_ClientProxy.getConnection(Unknown Source)
        at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56)

To Reproduce Steps to reproduce the behavior:

  1. Steps described in Reactive postgres guide (https://quarkus.io/guides/reactive-postgres-client}
  2. add flyway and postgre-jdbc dependencies to pom
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-flyway</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>

Additional context I was able work around this behavior with following steps:

  1. Changing config root to reactive-datasource in reactive postgres client ( https://github.com/quarkusio/quarkus/blob/master/extensions/reactive-pg-client/runtime/src/main/java/io/quarkus/reactive/pg/client/runtime/DataSourceConfig.java)
@ConfigRoot(name = "reactive-datasource", phase = ConfigPhase.RUN_TIME)
public class DataSourceConfig {
  1. application.properties
quarkus.reactive-datasource.url=vertx-reactive:postgresql://localhost:5432/quarkus_test
quarkus.reactive-datasource.username=quarkus_test
quarkus.reactive-datasource.password=quarkus_test

quarkus.datasource.url=jdbc:postgresql://localhost:5432/quarkus_test
quarkus.datasource.driver=org.postgresql.Driver
quarkus.datasource.username=quarkus_test
quarkus.datasource.password=quarkus_test

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 45 (40 by maintainers)

Most upvoted comments

As a side note, it might be good to support variables in application.properties so similar values can be reused. For example:

my.db.user=sarah
quarkus.datasource.username=${my.db.user}
quarkus.reactive-mysql-client.username=${my.db.user}

You can already do that!