datastax / cassandra-quarkus

An Apache Cassandra(R) extension for Quarkus
Apache License 2.0
39 stars 28 forks source link

Quarkus [1.13.3.Final] Classloader issue - works in QuarkusTest and not in quarkusDev. (Can't find class) #171

Closed rroopreddy closed 3 years ago

rroopreddy commented 3 years ago

Quarkus team recommended to enter the bug here. Details with duplicatable project is included here: https://github.com/quarkusio/quarkus/issues/17197


Quarkus [1.13.3.Final] Classloader issue - works in QuarkusTest and not in quarkusDev.

It works in test mode and not in quarkusDev mode. Seems like the System.getClassLoader() is different QuarkusTest vs gradle quarkusDev. Class.forName(className) is returning null for a class (JksSslEngineFactory ) specified for SSL configuration. Tried to attach ApplicationScoped to JksSslEngineFactory and various other approaches without much luck.


I think this is an issue with https://github.com/datastax/cassandra-quarkus

Basically it is not using the correct ClassLoader, instead of using the TCCL it appears to be using its own ClassLoader. I think the fix may be to add a getClassLoader method to com.datastax.oss.quarkus.runtime.internal.context.QuarkusDriverContext that always returns the TCCL, but I don't know enough about the extension to say for sure. Can you open an issue in their issue tracker?

┆Issue is synchronized with this Jira Task by Unito

adutra commented 3 years ago

Hi, thanks for reporting this.

The reasons why the driver doesn't use TCCL by default are explained here.

That said, if the Quarkus team says the TCCL should always be used, then I'm OK implementing the suggested changes.

Could you open a PR? The change IMO would be a one-liner; just change this line to:

        new QuarkusCqlSessionBuilder()
            .withConfigLoader(configLoaderBuilder.build())
            .withClassLoader(Thread.currentThread().getContextClassLoader());

If possible, add also an integration test that reproduces the issue (with a dummy subclass of DefaultSslEngineFactory).

rroopreddy commented 3 years ago

All the details are here: https://github.com/quarkusio/quarkus/issues/17197

Added the ZIP file with full project to duplicate the issue

test-project.zip