I have a modular Java / JavaFX, both Version 19 project in Eclipse. I use Maven to build the project. This project uses JAXB. The project runs fine within Eclipse if I use "clean javafx:run" as goal. In order to share the app, I wanted to create a runnable jar. In order to do that I used clean "javafx:jlink" as goal. This runs successful - well, to some extend. If I start the application on the Jlink image, the application starts, but it can't read the related user date since JAXB fails:
jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:252)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ContextFinder.find(ContextFinder.java:381)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)
at sifuSays@0.0.1-SNAPSHOT/de.levin.persistance.Persistance.loadSessions(Persistance.java:49)
at sifuSays@0.0.1-SNAPSHOT/de.levin.ctrl.MainCtrl.initialize(MainCtrl.java:1005)
at javafx.fxml@19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2655)
at javafx.fxml@19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml@19/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
at sifuSays@0.0.1-SNAPSHOT/de.levin.sifuSays.App.start(App.java:125)
at javafx.graphics@19/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics@19/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics@19/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics@19/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics@19/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics@19/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@19/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:113)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:146)
at jakarta.xml.bind@4.0.0/jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:250)
... 19 more
Many of the "solutions" that I found are several years old and refer to version 2.3.1. When I tried to use these old version, I can't fulfill the requirements regarding modules - at least I don't know how to fix that the module-info.java can resolve the error. Anyway, in addition to
jakarta.xml.bind
jakarta.xml.bind-api
4.0.0
I tried two different implementations in my pom.xml
org.glassfish.jaxb
jaxb-runtime
4.0.3
And, as recommended by Jakarta XML Binding
com.sun.xml.bind
jaxb-impl
4.0.3
runtime
old version.
The creation of the Jlink image is based on
org.openjfx
javafx-maven-plugin
0.0.8
package
default-cli
sifuSays/de.levin.sifuSays.App
launchSifuSays
always the same error message. I played around with several version combinations, but what strikes me, is that the error message always refers to v2. To trigger the build I use "clean javafx:jlink", so actually any old / wrong version should disappear from the build.
Any idea how to fix this? What would be interesting is why it works from within the Eclipse IDE? Maybe I need to reimplement the functionality with a different Java XML strategy?! If there is no reasonable way to fix the current setup, which XML approach is Java 11 using module architecture compliant?
Thank you in advance.