Skip to content

JAXB2 ClassCastException in Native Image (XmlSeeAlso$$ProxyImpl cannot be cast to Locatable) #25325

@dlabordus

Description

@dlabordus

Describe the bug

After upgrading Quarkus from 2.8.0 to 2.8.1 our RestEasy XML Endpoint is failing on generated JAXB2 Classes.

When a request is processed and the response should be returned Quarkus throws the following exception:

2022-05-03 08:16:13,974 WARN  [org.lfe.com.cor.jax.exc.GenericExceptionHandler] (executor-thread-0) Unknown exception occurred.: java.lang.ClassCastException: javax.xml.bind.annotation.XmlSeeAlso$$ProxyImpl cannot be cast to com.sun.xml.bind.v2.model.annotation.Locatable
	at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:260)
	at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:73)
	at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:54)
	at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getBaseClass(ClassInfoImpl.java:198)
	at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getBaseClass(RuntimeClassInfoImpl.java:125)
	at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getBaseClass(RuntimeClassInfoImpl.java:56)
	at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:248)

The native image worked with version 2.8.0. And also the non-native images still works with version 2.8.2.
The model is generated by a other maven project using JAXB2 from XSD Files.

The image is build using Maven with a Docker Container.
Command: mvn clean verify -Pnative -Dquarkus.container-image.build=true

It look like PR #24768 may have caused this, because searching for this kind of errors, often similar changes are mentions, but these are partially removed in this PR. Also in this PR there is a discussion about the GraalVM version 22.1, but with Quarkus 2.8.1 this is still 22.0, maybe this is something causing the problem.

Expected behavior

The response being created and returned.

Actual behavior

ClassCastException thrown

How to Reproduce?

No response

Output of uname -a or ver

Linux ubuntu 5.13.0-40-generic #45-Ubuntu SMP Tue Mar 29 14:48:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1) OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1, mixed mode, sharing)

GraalVM version (if different from Java)

Running Quarkus native-image plugin on GraalVM 22.0.0.2 Java 11 CE (Java Version 11.0.14+9-jvmci-22.0-b05)

Quarkus version or git rev

2.8.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: /home/dlabordus/.m2/wrapper/dists/apache-maven-3.8.1-bin/2l5mhf2pq2clrde7f7qp1rdt5m/apache-maven-3.8.1 Java version: 11.0.15, vendor: Private Build, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_GB, platform encoding: UTF-8 OS name: "linux", version: "5.13.0-40-generic", arch: "amd64", family: "unix"

Additional information

Part of the Maven output:

[INFO] --- quarkus-maven-plugin:2.8.2.Final:build (default) @ app ---
[WARNING] [io.quarkus.deployment.steps.ReflectiveHierarchyStep] Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
	- javax.xml.namespace.QName (source: SmallRyeOpenApiProcessor > org.lfenergy.compas.cim.mapping.rest.v1.model.MapResponse)
Consider adding them to the index either by creating a Jandex index for your dependency via the Maven plugin, an empty META-INF/beans.xml or quarkus.index-dependency properties.
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building native image source jar: /home/dlabordus/projects/compas/compas-cim-mapping/app/target/app-local-SNAPSHOT-native-image-source-jar/app-local-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from /home/dlabordus/projects/compas/compas-cim-mapping/app/target/app-local-SNAPSHOT-native-image-source-jar/app-local-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Using docker to run the native image builder
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildContainerRunner] Checking image status quay.io/quarkus/ubi-quarkus-native-image:22.0-java11
22.0-java11: Pulling from quarkus/ubi-quarkus-native-image
Digest: sha256:44fe2378937b3b0b6f64189f68fda629dfc090370239cec8a8f1496d3f1d96e7
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:22.0-java11
quay.io/quarkus/ubi-quarkus-native-image:22.0-java11
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM 22.0.0.2 Java 11 CE (Java Version 11.0.14+9-jvmci-22.0-b05)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildRunner] docker run --env LANG=C --rm --user 1000:1000 -v /home/dlabordus/projects/compas/compas-cim-mapping/app/target/app-local-SNAPSHOT-native-image-source-jar:/project:z --name build-native-hqVmc quay.io/quarkus/ubi-quarkus-native-image:22.0-java11 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=en -J-Duser.country=GB -J-Dfile.encoding=UTF-8 -H:-ParseOnce -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED --initialize-at-run-time=org.eclipse.rdf4j.common.iteration.TimeLimitIteration --initialize-at-run-time=org.apache.http.impl.auth.NTLMEngineImpl -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -J-Djava.awt.headless=true -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https -H:-UseServiceLoaderFeature -H:+StackTrace app-local-SNAPSHOT-runner -jar app-local-SNAPSHOT-runner.jar
========================================================================================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions