Search code examples
javamavengraalvmgraalvm-native-image

Error building native image with GraalVM native-image-maven-plugin


I'm creating a native image for a JavaFX application using native-image-maven-plugin with GraalVm 21.0.0.2. When I try to execute it after the build end successfully I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.xerces.parsers.ObjectFactory
at org.apache.xerces.parsers.ObjectFactory.class$(Unknown Source) 
at org.apache.xerces.parsers.ObjectFactory.findClassLoader(Unknown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)
at org.apache.xerces.parsers.ObjectFactory.createObject(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.parsers.DOMParser.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)

I appreciate any help you can give me.


Solution

  • Thanks to Jose Pereda comment I was able to build the native image using the Gluon plugin. I used the gluon plugin samples. But firs I needed to bump my code to parse XML using Stax instead of Sax: parse XML in java.