Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError in ShutdownTask when running BuildMetricsTest #44641

Closed
gsmet opened this issue Nov 22, 2024 · 7 comments · Fixed by #44677
Closed

NoClassDefFoundError in ShutdownTask when running BuildMetricsTest #44641

gsmet opened this issue Nov 22, 2024 · 7 comments · Fixed by #44677

Comments

@gsmet
Copy link
Member

gsmet commented Nov 22, 2024

I just got this error logged when running the Vert.x HTTP tests with main. Note that it doesn't fail the build.

Also apparently, we arealdy did some work inQuarkusJacksonFactory to avoid the problem:

    public static void reset() {
        // if we blindly reset, we could get NCDFE because Jackson classes would not have been loaded
        if (COUNTER.get() > 0) {
            QuarkusJacksonJsonCodec.reset();
        }
    }
[INFO] Running io.quarkus.devui.BuildMetricsTest
2024-11-22 12:09:36,224 WARN  [io.qua.boo.BootstrapAppModelFactory] (main) Expected project directory /home/gsmet/git/quarkus/extensions/vertx-http/deployment/target/quarkus-dev-mode-test2419565303631823258 does not match current project directory /home/gsmet/git/quarkus/extensions/vertx-http/deployment
2024-11-22 12:09:37,993 INFO  [org.jbo.threads] (main) JBoss Threads version 3.8.0.Final
Tests paused
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
            Powered by Quarkus 999-SNAPSHOT
2024-11-22 12:09:39,315 INFO  [io.quarkus] (Quarkus Main Thread) quarkus-vertx-http-deployment 999-SNAPSHOT on JVM (powered by Quarkus 999-SNAPSHOT) started in 1.771s. Listening on: http://localhost:8080
2024-11-22 12:09:39,317 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2024-11-22 12:09:39,317 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, security, smallrye-context-propagation, vertx]
2024-11-22 12:09:42,480 ERROR [io.qua.run.StartupContext] (Quarkus Main Thread) Running a shutdown task failed [Error Occurred After Shutdown]: java.lang.NoClassDefFoundError: Could not initialize class io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec
	at io.quarkus.vertx.runtime.jackson.QuarkusJacksonFactory.reset(QuarkusJacksonFactory.java:39)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.run(VertxCoreRecorder.java:591)
	at io.quarkus.runtime.StartupContext.runAllAndClear(StartupContext.java:79)
	at io.quarkus.runtime.StartupContext.close(StartupContext.java:70)
	at io.quarkus.runner.ApplicationImpl.doStop(Unknown Source)
	at io.quarkus.runtime.Application.stop(Application.java:208)
	at io.quarkus.runtime.Application.stop(Application.java:155)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:238)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:116)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.IllegalStateException: There was no ObjectMapper bean configured [in thread "executor-thread-1"]
	at io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec.populateMapper(QuarkusJacksonJsonCodec.java:66)
	at io.quarkus.vertx.runtime.jackson.QuarkusJacksonJsonCodec.<clinit>(QuarkusJacksonJsonCodec.java:38)
	at io.quarkus.vertx.runtime.jackson.QuarkusJacksonFactory.codec(QuarkusJacksonFactory.java:22)
	at io.vertx.core.json.Json.<clinit>(Json.java:28)
	at io.vertx.core.json.JsonObject.fromJson(JsonObject.java:1262)
	at io.vertx.core.json.JsonObject.<init>(JsonObject.java:51)
	at io.quarkus.devui.runtime.build.BuildMetricsDevUIController.prepareBuildStepsMetrics(BuildMetricsDevUIController.java:75)
	at io.quarkus.devui.runtime.build.BuildMetricsDevUIController.getBuildStepsMetrics(BuildMetricsDevUIController.java:60)
	at io.quarkus.devui.runtime.build.BuildMetricsJsonRPCService.buildStepMetrics(BuildMetricsJsonRPCService.java:57)
	at io.quarkus.devui.runtime.build.BuildMetricsJsonRPCService.getBuildMetrics(BuildMetricsJsonRPCService.java:32)
	at io.quarkus.devui.runtime.build.BuildMetricsJsonRPCService_ClientProxy.getBuildMetrics(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.devui.runtime.comms.JsonRpcRouter.lambda$invoke$12(JsonRpcRouter.java:323)
	at io.smallrye.mutiny.unchecked.UncheckedSupplier.lambda$toSupplier$0(UncheckedSupplier.java:41)
	at io.smallrye.context.impl.wrappers.SlowContextualSupplier.get(SlowContextualSupplier.java:21)
	at io.smallrye.mutiny.operators.uni.builders.UniCreateFromItemSupplier.subscribe(UniCreateFromItemSupplier.java:28)
	at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
	at io.smallrye.mutiny.operators.uni.UniRunSubscribeOn.lambda$subscribe$0(UniRunSubscribeOn.java:27)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:637)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
	at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	... 1 more
Copy link

quarkus-bot bot commented Nov 22, 2024

/cc @ebullient (metrics), @jmartisk (metrics)

@gsmet
Copy link
Member Author

gsmet commented Nov 22, 2024

/cc @geoand @mkouba

@geoand
Copy link
Contributor

geoand commented Nov 22, 2024

Thanks for raising!

I'll have a look next week

@mkouba
Copy link
Contributor

mkouba commented Nov 22, 2024

FYI I was able to reproduce the issue with mvn clean test -Dtest=BuildMetricsTest in the quarkus/extensions/vertx-http/deployment directory. But as mentioned above the error occurrs after shutdown and the test just passed.

@mkouba
Copy link
Contributor

mkouba commented Nov 22, 2024

It might be a regression caused by #44373. There is a new shutdown task that executes QuarkusJacksonFactory.reset() but apparently the class loader calls the static initializer of QuarkusJacksonJsonCodec and the ObjectMapperProducer is not registered... not sure why 🤷

@geoand
Copy link
Contributor

geoand commented Nov 25, 2024

It might be a regression caused by #44373

This turns out to be both true and false :).

It's true because without #44373 there is stacktrace showing up in the output, but it's also false because even without #44373 the exception is still thrown (which expected in the test case). What I need to figure out is why #44373 is making the stacktrace show up in the logs

@geoand
Copy link
Contributor

geoand commented Nov 25, 2024

#44677 fixes the problem

@geoand geoand closed this as completed in a033231 Nov 25, 2024
geoand added a commit that referenced this issue Nov 25, 2024
Properly reset Quarkus populated Jackson ObjectMapper
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Nov 25, 2024
@gsmet gsmet modified the milestones: 3.18 - main, 3.17.1 Nov 27, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants