datastax / cassandra-quarkus

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

Cassandra extension breaks new quarks project #203

Closed knoma closed 2 years ago

knoma commented 2 years ago

When I create a new project with quarkus 2.6 and cassandra-quarkus-client, I can't start the project it fails due a exception, no other extensions are loaded.

> Task :quarkusDev
Listening for transport dt_socket at address: 5005
Press [h] for more options>
2022-01-24 13:20:04,010 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
2022-01-24 13:20:04,135 INFO  [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
2022-01-24 13:20:04,200 INFO  [org.jbo.threads] (main) JBoss Threads version 3.4.2.Final
2022-01-24 13:20:04,286 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.vertx.core.deployment.VertxCoreProcessor#createVertxThreadFactory threw an exception: java.lang.NoSuchMethodError: 'java.util.concurrent.ThreadFactory io.quarkus.vertx.core.runtime.VertxCoreRecorder.createThreadFactory()'
        at io.quarkus.vertx.core.deployment.VertxCoreProcessor.createVertxThreadFactory(VertxCoreProcessor.java:133)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:330)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:93)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:456)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:67)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:150)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:106)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.vertx.core.deployment.VertxCoreProcessor#createVertxThreadFactory threw an exception: java.lang.NoSuchMethodError: 'java.util.concurrent.ThreadFactory io.quarkus.vertx.core.runtime.VertxCoreRecorder.createThreadFactory()'
        at io.quarkus.vertx.core.deployment.VertxCoreProcessor.createVertxThreadFactory(VertxCoreProcessor.java:133)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

        at io.quarkus.builder.Execution.run(Execution.java:116)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:157)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:328)
        ... 9 more
Caused by: java.lang.NoSuchMethodError: 'java.util.concurrent.ThreadFactory io.quarkus.vertx.core.runtime.VertxCoreRecorder.createThreadFactory()'
        at io.quarkus.vertx.core.deployment.VertxCoreProcessor.createVertxThreadFactory(VertxCoreProcessor.java:133)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
        at java.base/java.lang.Thread.run(Thread.java:829)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)

┆Issue is synchronized with this Jira Task by Unito

adutra commented 2 years ago

Hi @knoma thanks for reporting this.

When I download a sample app from https://code.quarkus.io indeed I can reproduce the issue using Gradle, however when using Maven everything works as expected:

2022-01-24 17:23:44,661 INFO  [com.dat.oss.qua.dep.int.CassandraClientProcessor] (build-8) Cassandra metrics were disabled by configuration.
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-01-24 17:23:45,588 INFO  [io.quarkus] (Quarkus Main Thread) code-with-quarkus 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.6.3.Final) started in 2.645s. Listening on: http://localhost:8080

2022-01-24 17:23:45,592 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2022-01-24 17:23:45,593 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cassandra-client, cdi, resteasy, smallrye-context-propagation, smallrye-health, vertx]
2022-01-24 17:28:06,185 INFO  [io.quarkus] (Shutdown thread) code-with-quarkus stopped in 0.015s

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

So this must be something related to Gradle. @Miles-Garnsey I recall that you hit this issue too, do you remember how you managed to fix it?

Miles-Garnsey commented 2 years ago

From recollection I may have moved back down to Quarkus 2.4.2 and that resolved a lot of these problems.

@knoma can you share the versions of Gradle, Quarkus, JVM, and Cassandra-Quarkus extension you are using? If you can share a whole repo (so we can see your build.gradle etc. that's even better).

Miles-Garnsey commented 2 years ago

I just tested this a bit more thoroughly and can confirm I replicate this issue with Quarkus 2.6.2.Final but I don't see it with 2.6.2.Final (I just selected these versions somewhat at random, don't read too much into the specific patch versions I chose).

knoma commented 2 years ago

thank you both, I used quarkus2.6.3.Final, jdk11 and Gradle 7.3.3 - here a link to the repo

https://github.com/knoma/quarkus-cass.git

➜  quarkus-cass-3 java --version
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)
➜  quarkus-cass-3 ./gradlew --version

------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------

Build time:   2021-12-22 12:37:54 UTC
Revision:     6f556c80f945dc54b50e0be633da6c62dbe8dc71

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.12 (Homebrew 11.0.12+0)
OS:           Mac OS X 12.1 aarch64
Miles-Garnsey commented 2 years ago

@knoma you will definitely make better progress on a Quarkus 2.4.x version.

@adutra would it be worth building some Dependabot setup for this project which automatically raise PRs when new Quarkus versions are released? Or having some e2e tests built in to test for gradle-based use cases?

adutra commented 2 years ago

OK I investigated a bit and it turns out you can fix the problem by adding this in build.gradle inside the dependencies block:

    implementation 'io.quarkus:quarkus-vertx'

I don't understand exactly why the same is not needed for Maven.

I also don't fully understand why this dependency is not being added automatically by start.quarkus.io; but one thing that we can certainly do is explicitly list quarkus-vertx as a dependency of cassandra-client. Vertx is used in the client, see MutinyWrappers, so it seems legit to add it.

adutra commented 2 years ago

@adutra would it be worth building some Dependabot setup for this project which automatically raise PRs when new Quarkus versions are released? Or having some e2e tests built in to test for gradle-based use cases?

Absolutely, we need those! In fact I'd advocate for migrating from our internal CI system to GitHub Actions. Our CI system is pretty much saturated at this point.

knoma commented 2 years ago

thank you @adutra for the time you put in - works now.