1

Hi i upgraded an old java 8 project to a java 11 to use Graalvm for building native image, first problem was with how should i add external jar files to the project and i did it using a maven plugin, then after compiling and linking the project successfully, the application gave an error JavaFx configuration: classes were loaded from unnamed module. I had solved this problem in the IDE using VM options --module-path javafx-sdk-19/lib --add-modules javafx.fxml,javafx.controls,javafx.graphics,and after adding the runtimeArgs still no luck running the native image.

How can i make the native image use external javafx sdk like in the IDE?

Maven plugin for adding external jars

 <plugin>
            <groupId>com.googlecode.addjars-maven-plugin</groupId>
            <artifactId>addjars-maven-plugin</artifactId>
            <version>1.0.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>add-jars</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>${basedir}/libs</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Gluonfx plugin

            <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>gluonfx-maven-plugin</artifactId>
            <version>1.0.15</version>
            <configuration>
                <mainClass>com.proj.main.Main</mainClass>
                <reflectionList>com.proj.main.PaxUtils</reflectionList>
                <reflectionList>com.proj.JsonUtil</reflectionList>
                 <nativeImageArgs>
                    <arg>+EagerJVMCI</arg>
                    <arg>-Dgraal.PrintConfiguration=info</arg>
                </nativeImageArgs>
            </configuration>
        </plugin>

Error log

WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @7e0babb1'

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:901)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.lang.Thread.run(Thread.java:829)
    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.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:164)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2835)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:1068)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1841)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1769)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:148)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:54)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:40)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.getProviderFactory(ResteasyClientBuilder.java:456)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.buildOld(ResteasyClientBuilder.java:464)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:496)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:50)
    at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
    at com.xylo.client.xpos.service.XWebServiceClient.init(XWebServiceClient.java:41)
    at com.xylo.client.xpos.service.XWebServiceClient.<init>(XWebServiceClient.java:31)
    at com.xylo.client.xpos.POSSettings.fillSettings(POSSettings.java:181)
    at com.xylo.client.xpos.main.Main.start(Main.java:45)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.security.AccessController.executePrivileged(AccessController.java:169)
    at java.security.AccessController.doPrivileged(AccessController.java:91)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    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$11(GtkApplication.java:316)
    ... 3 more
Caused by: java.lang.IllegalArgumentException: Invalid bundle interface org.jboss.resteasy.resteasy_jaxrs.i18n.Messages (implementation not found)
    at org.jboss.logging.Messages.doGetBundle(Messages.java:92)
    at org.jboss.logging.Messages.getBundle(Messages.java:59)
    at org.jboss.logging.Messages.getBundle(Messages.java:46)
    at org.jboss.resteasy.resteasy_jaxrs.i18n.Messages.<clinit>(Messages.java:31)
    ... 30 more
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • can you use `` instead of `` and split it in two `` tags, so there are no blank spaces? – José Pereda Oct 06 '22 at 10:24
  • It gives `Error parsing Graal options: Could not find option PrintConfiguration` and does not complete the build (I updated the plugin code above) – Yousef Hamarsheh Oct 06 '22 at 10:33
  • Maybe comment out for now the print option. And your reflection list is wrong too, btw. – José Pereda Oct 06 '22 at 10:50
  • Okay i will try and fix it, but is there any other way to use external javafx sdk other than the one presented? – Yousef Hamarsheh Oct 06 '22 at 10:54
  • 1
    The message `JavaFX configuration: classes were loaded from unnamed module` is just a warning, you can ignore it for now. To fix it you would have to modify the GraalVM options to include module-path and alike. – José Pereda Oct 06 '22 at 10:57

0 Answers0