NoClassDefFoundError error with JDBCPool in vertx 4.3.2

418 Views Asked by At

I am getting error with new JDBCClient API.

java.lang.NoClassDefFoundError: io/agroal/api/configuration/supplier/AgroalDataSourceConfigurationSupplier

Created project from starter, included jdbc-client and H2 database API.

JDBCPool pool = JDBCPool.pool(
      vertx,
      // configure the connection
      new JDBCConnectOptions()
        // H2 connection string
        .setJdbcUrl("jdbc:h2:~/test")
        // username
        .setUser("sa")
        // password
        .setPassword(""),
      // configure the pool
      new PoolOptions()
        .setMaxSize(16)
    );

while retrieving connection getting NoClassDefFoundError

1

There are 1 best solutions below

1
On BEST ANSWER

Given that the vert.x client requires a pool, all pool implementations are marked as optional dependencies and your build tool does not pull it to your project. Which means you need to explicitly add it; otherwise you will see that error. For this case, you will need:

io.agroal:agroal-api1.16
io.agroal:agroal-pool:1.16

For the future, the plan is to rely just on a javax.sql.DataSource and keep the pool agnostic. Most pools do implement this interface, so users are free to choose to use a pool or not.