smallrye / smallrye-health

Home Page:https://smallrye.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClassNotFoundException: javax.json.JsonValue when upgrading to Quarkus 2.5.3

tomwetjens opened this issue · comments

After upgrading to Quarkus 2.5.3, javax.json is no longer on the class path since it is replaced with jakarta.json.

Running the application now fails with:

Caused by: java.lang.NoClassDefFoundError: javax/json/JsonValue
        at java.base/java.lang.Class.getDeclaredFields0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredFields(Class.java:3139)
        at java.base/java.lang.Class.getDeclaredField(Class.java:2487)
        at io.quarkus.arc.impl.Reflections.findFieldInternal(Reflections.java:64)
        at io.quarkus.arc.impl.Reflections$1.apply(Reflections.java:33)
        at io.quarkus.arc.impl.Reflections$1.apply(Reflections.java:30)
        at io.quarkus.arc.impl.ComputingCache$1.get(ComputingCache.java:52)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:49)
        at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:40)
        at io.quarkus.arc.impl.Reflections.findField(Reflections.java:59)
        at io.smallrye.health.SmallRyeHealthReporter_Bean.<init>(Unknown Source)
        at io.quarkus.arc.setup.Default_ComponentsProvider.addBeans3(Unknown Source)
        at io.quarkus.arc.setup.Default_ComponentsProvider.getComponents(Unknown Source)
        at io.quarkus.arc.impl.ArcContainerImpl.<init>(ArcContainerImpl.java:118)
        at io.quarkus.arc.Arc.initialize(Arc.java:20)
        ... 21 more
Caused by: java.lang.ClassNotFoundException: javax.json.JsonValue
        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 io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:455)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:405)
        ... 38 more

Hi @tomwetjens, I've just tried Quarkus 2.5.3 with smallrye-health extension and it works correctly. Do you have a small reproducer to see what I'm missing?

I'm pretty sure that Quarkus still didn't switch to jakarta.* namespace and it wouldn't do it in minor release for sure since this is a breaking change.

As I was trying to create a reproducer from the quickstart, I found out that somehow through parent POMs, the version of org.glassfish:jakarta.json was managed to 2.0.1, whereas quarkus comes with 1.1.6. The former has the jakarta.json classes and the latter still has the javax.json classes.

Removing this version override did the trick to make it work!