gluonhq / gluonfx-gradle-plugin

Plugin that simplifies using Gluon Client for Java/JavaFX gradle projects
BSD 3-Clause "New" or "Revised" License
100 stars 22 forks source link

Cannot run native image for JavaFX+Spring Boot project #173

Closed palexdev closed 1 year ago

palexdev commented 1 year ago

I have an app built with Spring Boot and JavaFX. I need to distribute my app on all major platforms, and I'd like to use GraalVM to generate native images. However, little did I know the process would be so underwhelming, I tried everything, but I can't make this work, it's so difficult

I have made a little reproducer, available here: Reproducer.zip

I can't run the app because I get this exception:

[Sun Jun 04 12:32:02 CEST 2023][INFO] ==================== LINK TASK ====================
[Sun Jun 04 12:32:03 CEST 2023][INFO] [SUB] Jun 04, 2023 12:32:03 PM com.sun.javafx.application.PlatformImpl startup
[Sun Jun 04 12:32:03 CEST 2023][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @71c7db30'
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB] Exception in Application constructor
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Unable to construct Application instance: class io.github.palexdev.reproducer.Reproducer
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:883)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at java.lang.Thread.run(Thread.java:833)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB] Caused by: java.lang.NoSuchMethodException: io.github.palexdev.reproducer.Reproducer.<init>()
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at java.lang.Class.getConstructor0(DynamicHub.java:3585)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at java.lang.Class.getConstructor(DynamicHub.java:2271)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:794)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at java.security.AccessController.executePrivileged(AccessController.java:169)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at java.security.AccessController.doPrivileged(AccessController.java:399)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST_Runnable_run_16403f8d32adb631126daa893e5e80085c5d6325(JNIJavaCallWrappers.java:0)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.glass.ui.gtk.GtkApplication._runLoop(GtkApplication.java)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
[Sun Jun 04 12:32:04 CEST 2023][INFO] [SUB]     ... 3 more
[Sun Jun 04 12:32:03 CEST 2023][INFO] ==================== RUN TASK ====================

Also note that I can't run the nativeRunAgent task because I recieve an exception of type UnsupportedOperationException with no message, so I don't know what's causing it

palexdev commented 1 year ago

YOOOO?? ANYBODY HERE??? Where the heck is support? There is a mountain of issue here without any answer I believe #159 needs to be merged ASAP

alextim1508 commented 1 year ago

Hi! Have you solved the problem?

palexdev commented 1 year ago

Hi! Have you solved the problem?

Yes, by not using Spring, replaced by Inverno

Also, if you wanna know the outcome, I was able to consistently build native images but they are very buggy So I ended up using JLink