vert-x3 / issues

Apache License 2.0
36 stars 7 forks source link

Java Vert.x JDBC client runtime load error: Could not load driverClass com.mysql.cj.jdbc.Driver java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver #535

Closed khteh closed 4 years ago

khteh commented 4 years ago

Questions

I have the following dependency in pom.xml:

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.20</version>
            <scope>runtime</scope>
        </dependency>

My MySQL server is 8.0.20. Running my Java Vert.x application from the command line vertx run com.restapi.vertx.Launcher -cp target/* bumps into the following runtime exception:

Could not load driverClass com.mysql.cj.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:340)
        at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:143)
        at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:173)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)`

Version

Which version(s) did you encounter this bug ? 3.9.1

Context

Using JDBC in Java Vert.x application to access MySQL 8.0.20

tsegismont commented 4 years ago

I just tried your reproducer (#533) and after changing the vertx-jdbc-client version to 3.9.1, the app started and the JDBC driver was found.

tsegismont commented 4 years ago

Closing this as there is no Vert.x issue. Please post further questions to the Vert.x user group (see https://vertx.io/community/).

khteh commented 4 years ago

Which command did you use? Using vertx CLI (vertx run com.restapi.vertx.Launcher -cp target/*) doesn't work but java does.

khteh commented 4 years ago

I have fixed the version to 3.9.1 but vertx run com.restapi.vertx.Launcher -cp target/* still bumps into the same exception:

Could not load driverClass com.mysql.cj.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver