Quarkus: Multiple NoClassDefFoundError with SVM built with jdk11u

Created on 23 Mar 2020  路  23Comments  路  Source: quarkusio/quarkus

jdk11u now contains the necessary bits to build a JDK with static libraries, which is required to build substratevm. While testing a snapshot JDK built out of there the following error has appeared:

Caused by: java.lang.NoClassDefFoundError: [Lorg/springframework/http/HttpMethod;
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
        at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.getDeclaredMethods(HotSpotResolvedObjectTypeImpl.java:932)
        at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.declaresDefaultMethods(ClassInitializationFeature.java:375)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.processInterfaces(ConfigurableClassInitialization.java:580)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:556)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.computeInitKindAndMaybeInitializeClass(ConfigurableClassInitialization.java:130)
        at com.oracle.svm.hosted.classinitialization.ConfigurableClassInitialization.maybeInitializeHosted(ConfigurableClassInitialization.java:158)
        at com.oracle.svm.hosted.SVMHost.registerType(SVMHost.java:200)

Longer output can be found here.

We've had a little Zulip conversation here, and we've discovered that HttpMethod is not included in the jar. The question is, why does it get into the pointsto analysis with this particular JDK? Further analysis is required.

arespring kinbug triagout-of-date

All 23 comments

/cc @geoand

The labs JDK contains newer JVMCI code that invokes into CompilerToVm.getDeclaredMethods() which does not fail if a method referencing a not found type is found. jdk11u is still using the old style which means this kind of CNFEs can happen, even if ResponseEntity$HeadersBuilder.allow(HttpMethod[]) method is not in use. I'm looking into the commits that added these changes to see if they can be backported to jdk11u.

Thanks for the update @galderz!

The code changes required to bring JVMCI code up to the newer version are too much. So, for the time being we're going to explore the option of adding missing classes to jars.

These extra classes do not make it to the final native image, nor do they have an impact on the JVM mode. So, it's a relatively safe option. Next few days I will explore which other classes are required to satisfy this.

Ok @galderz let us know when and what you want to add;

Another one impacted (longer output):

Caused by: java.lang.NoClassDefFoundError: org/openxmlformats/schemas/wordprocessingml/x2006/main/CTTextDirection
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.getDeclaredMethods(HotSpotResolvedObjectTypeImpl.java:932)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.declaresDefaultMethods(ClassInitializationFeature.java:375)

Looks like an issue with Tika, no?

Yeah, an issue in one of the jars. I'm looking into that this morning.

Changed the description to encompass other possible situations, not just spring web.

Good idea!

The tika/poi issue is fixed with #8185.

Main quarkus native testsuite passes now.

@geoand, you can go ahead and merge the spring-web api PR. Could you also release a new version and upgrade quarkus tree?

@galderz of course.

Thanks for checking.
I will let you know when a new release is available.

I've noticed yet another one, but this time in the quarkus-platform testsuite:

[quarkus-universe-integration-tests-camel-aws-999-SNAPSHOT-runner:26810]     analysis:   4,843.12 ms,  1.19 GB
Fatal error:org.graalvm.compiler.debug.GraalError: Unable to resolve all classes in class: org.apache.camel.spi.ModelJAXBContextFactory
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.declaresDefaultMethods(ClassInitializationFeature.java:386)
    ...
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.getDeclaredMethods(HotSpotResolvedObjectTypeImpl.java:932)
    at com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.declaresDefaultMethods(ClassInitializationFeature.java:378)

Longer output here.

@lburgazzoli ^

@ppalaga @jamesnetherton ^

Re:camel, when running with labs JDK, I see this message:

16:36:14,396 WARN [com.ama.uti.Base64] JAXB is unavailable. Will fallback to SDK implementation which may be less performant.If you are using Java 9+, you will need to include javax.xml.bind:jaxb-api as a dependency.

A similar issue was appearing with Labs JDK, so I expect this latest failure with jdk11u-dev to go away. I'll test in the next few days.

@geoand Have you already updated the Spring dependency to avoid this issue? If not, any estimates when you expect to do this?

@galderz yes, the fix is in Quarkus master

Awesome @geoand, one less patch I need to keep track of :)

With the spring and ooxml-schemas issues integrated, I think I can close this for now. I still need to test Camel, but if that fails I'll open an issue on their project. Thx everyone for their help!

Thanks for reporting and for your help @galderz!

Was this page helpful?
0 / 5 - 0 ratings