Skip to content

Webjars broken with Quarkus 3.16 due to an exception in Classgraph #891

@triceo

Description

@triceo

In code that worked with Quarkus 3.15, I am now getting the following exception after upgrading to Quarkus 3.16:

java.lang.RuntimeException: Exception while calling findClassLoaderOrder for nonapi.io.github.classgraph.classloaderhandler.QuarkusClassLoaderHandler
at nonapi.io.github.classgraph.classloaderhandler.ClassLoaderHandlerRegistry$ClassLoaderHandlerRegistryEntry.findClasspathOrder(ClassLoaderHandlerRegistry.java:239)
at nonapi.io.github.classgraph.classpath.ClasspathFinder.<init>(ClasspathFinder.java:277)
at io.github.classgraph.Scanner.<init>(Scanner.java:170)
at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1562)
at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1590)
at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1615)
at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1654)
at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1667)
at org.webjars.WebJarAssetLocator.scanForWebJars(WebJarAssetLocator.java:188)
at org.webjars.WebJarAssetLocator.<init>(WebJarAssetLocator.java:210)
at org.webjars.WebJarAssetLocator.<init>(WebJarAssetLocator.java:198)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at nonapi.io.github.classgraph.classloaderhandler.ClassLoaderHandlerRegistry$ClassLoaderHandlerRegistryEntry.findClasspathOrder(ClassLoaderHandlerRegistry.java:236)
... 21 more
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Collection.iterator()" because the return value of "nonapi.io.github.classgraph.reflection.ReflectionUtils.getFieldVal(boolean, Object, String)" is null
at nonapi.io.github.classgraph.classloaderhandler.QuarkusClassLoaderHandler.findClasspathOrderForQuarkusClassloader(QuarkusClassLoaderHandler.java:120)
at nonapi.io.github.classgraph.classloaderhandler.QuarkusClassLoaderHandler.findClasspathOrder(QuarkusClassLoaderHandler.java:111)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 23 more

The following code in Classgraph seems to trigger the exception:

for (final Object element : (Collection<Object>) classpathOrder.reflectionUtils.getFieldVal(false,
            classLoader, "elements")) {
     ...
}

I'm assuming some behavior of the Quarkus ClassLoader changed in 3.16? I do not know any details about this though.

I attempted manually forcing the latest version of Classgraph (4.8.177), but exception persists.

$ java -version
openjdk version "21.0.5" 2024-10-15 LTS
OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions