0

I have a GluonFX GraalVM app that I managed to build using a Maven pom file. When I run it appears to fail loading the runtime glassfish libs on calling JAXBContext.newInstance():

$ ./app
Jul 17, 2023 3:30:00 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @71c7db30'
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.lang.Thread.run(Thread.java:833)
    at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
    at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
Caused by: java.lang.ExceptionInInitializerError
    at org.glassfish.jaxb.runtime.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:61)
    at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:405)
    at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:255)
    at org.glassfish.jaxb.runtime.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1115)
    at org.glassfish.jaxb.runtime.v2.ContextFactory.createContext(ContextFactory.java:144)
    at org.glassfish.jaxb.runtime.v2.JAXBContextFactory.createContext(JAXBContextFactory.java:44)
    at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:368)
    at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
    at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)
    ...
com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
    at java.security.AccessController.executePrivileged(AccessController.java:169)
    at java.security.AccessController.doPrivileged(AccessController.java:399)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_Runnable_run_16403f8d32adb631126daa893e5e80085c5d6325(JNIJavaCallWrappers.java:0)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(GtkApplication.java)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:263)
    ... 3 more
Caused by: java.lang.IllegalStateException: ReflectionNavigator.getInstance can't be found
    at org.glassfish.jaxb.runtime.v2.model.impl.Utils$1.run(Utils.java:55)
    at org.glassfish.jaxb.runtime.v2.model.impl.Utils$1.run(Utils.java:47)
    at java.security.AccessController.executePrivileged(AccessController.java:169)
    at java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.glassfish.jaxb.runtime.v2.model.impl.Utils.<clinit>(Utils.java:46)
    ... 27 more

My pom.xml relevant dependencies are:

        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/jakarta.activation/jakarta.activation-api -->
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>4.0.0</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>4.0.0</version>
            <scope>runtime</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.istack/istack-commons-runtime -->
        <dependency>
            <groupId>com.sun.istack</groupId>
            <artifactId>istack-commons-runtime</artifactId>
            <version>3.0.11</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId> <!-- needed at runtime but not part of glassfish -->
            <artifactId>txw2</artifactId>
            <version>4.0.0</version>
            <scope>runtime</scope>
        </dependency>

The application works when I run not as a standalone GraalVM app on both command-line and through Eclipse, but there is something I'm missing in telling GraalVM where to find the Jakarta JAXB libs at runtime.

Linux Mint21 Java 17 GluonFX GraalVM graalvm-svm-java17-linux-gluon-22.1.0.1-Final

Graham Seed
  • 742
  • 3
  • 10
  • 24
  • Did you run `mvn gluonfx:runagent` before building the native image? That should help finding out reflective cases like this. Then build and run again? – José Pereda Jul 17 '23 at 15:11
  • Jose Peresda - Thanks, that sorted out what wasn't "open". However, I am now onto the next series of issues. – Graham Seed Jul 17 '23 at 18:45

1 Answers1

0

most of the dependencies here are marked as runtime dependencies. Can they work with GRAALVMs initialize-at-run-time parameter?. Apart from this, I am assuming your libs are compatible with native image, you can apply tracing agent https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/#:~:text=GraalVM%20provides%20a%20Tracing%20Agent,on%20a%20regular%20Java%20VM. and see reflections, jni s can be defined. My method once the tracing output generated I add all of them to native image compilation, then I remove them piece by piece until I have found minimal tracing agent config.

Mustafayl
  • 15
  • 6
  • Hello, please don't ask new questions and provide your answer with a sample code. – Endery Aug 25 '23 at 06:51
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 25 '23 at 06:51