2

嗨,我一直在尝试对我的 javafx 项目进行本地构建,但是当我尝试运行它时出现异常。我怀疑在编译的二进制文件中找不到 .fxml 文件

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:479)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
Caused by: java.lang.AssertionError: java.lang.ClassNotFoundException: javafx.fxml.FXMLLoader
        at com.sun.javafx.util.Utils.forceInit(Utils.java:858)
        at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
        at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:350)
        at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:270)
        at java.lang.Class.ensureInitialized(DynamicHub.java:475)
        at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056)
        at com.oracle.svm.core.hub.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:350)
        at com.oracle.svm.core.hub.ClassInitializationInfo.initialize(ClassInitializationInfo.java:270)
        at java.lang.Class.ensureInitialized(DynamicHub.java:475)
        at loliSnatcher.WindowManager.searchWindowLoader(WindowManager.java:21)
        at loliSnatcher.Main.start(Main.java:10)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
        at java.security.AccessController.doPrivileged(AccessController.java:98)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java:0)
        at com.sun.glass.ui.gtk.GtkApplication._runLoop(GtkApplication.java)
        at com.sun.glass.ui.gtk.GtkApplicat[ion[a1mb;d3a$4rmunILNooFp$O1(Gtk[Ampp]l ic[ti1omn.-ja-v-a-:-2-77-)-
-       ...- 3- -m-or-e-
-C-au-s-e-d- -b-y-:- -j-a-v-a-.-l-an-g-.-C-la-s-s-No-tF-o-u-n-dE-x-c-e-p-ti-o-n:- j-a-va-f-x-.f-x-ml-.-FX-M-L-L-oa-d-er
-       -a-t- -cm[.mor
acle.svm.core.hub.ClassFo[r[a1m;e3S4umppIoNrFtO.[omr]N a[e1(;C3l2amsBsUFIoLrNDa mSeUSCuCpEpSoSr[.mj
ava:60)
        at ja[v[.1l;a3n4gm.ICNlFaOsm.]f o[N1amm-e-(-D-y-n-a-m-i-c-H-u-b-.-j-a-v-a-:-1-1-9-7-)-
--      -a-t- -c--o--m--.--s--u-n-.-j-a-v-a-f-x-.-u-t-i-l-.-U-t-il-s-.-f-o-r-c-e-I-n-i-t--(-U-t[lms
.java:855)

我不确定我做错了什么,因为如果我使用 mvn 运行程序,它运行得非常好javafx:run

我想知道我的 pom 文件是错误的还是我以前从未使用过 maven 的东西,所以只是尝试复制此处找到的示例项目中的内容:

https://github.com/gluonhq/client-samples https://gluonhq.com/native-desktop-application-using-substrate-graalvm/

这是我当前的源代码帮助/洞察力将不胜感激https://files.catbox.moe/xdr8x8.zip

我认为它可能是 pom 文件,这里有一些 refelction 列表,其中列出了一堆 javafx 的东西,但我不确定我是否需要添加我在这里使用的每一个 javafx 东西或https://github .com/gluonhq/client-samples/blob/master/Maven/HelloFXML/pom.xml

4

1 回答 1

1

好的,我发现了我必须将所有类添加到 pom.xml 中的反射列表的问题

    <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>client-maven-plugin</artifactId>
                <version>${client.plugin.version}</version>
                <configuration>
                    <reflectionList>
                        <list>javafx.application.Application</list>
                        <list>javafx.fxml.FXMLLoader</list>
                        <list>javafx.beans.value.ObservableValue</list>
                        <list>javafx.event.ActionEvent</list>
                        <list>javafx.event.EventHandler</list>
                        <list>javafx.scene.image.Image</list>
                        <list>javafx.fxml.FXML</list>
                        <list>javafx.scene.control.ScrollPane</list>
                        <list>javafx.scene.control.TextField</list>
                        <list>javafx.scene.image.ImageView</list>
                        <list>javafx.scene.input.MouseEvent</list>
                        <list>javafx.scene.layout.FlowPane</list>
                        <list>javafx.scene.layout.StackPane</list>
                        <list>javafx.scene.Parent</list>
                        <list>javafx.scene.Scene</list>
                        <list>javafx.stage.Stage</list>
                        <list>java.util.ArrayList</list>
                        <list>javafx.scene.control.ComboBox</list>
                        <list>javafx.scene.control.ListCell</list>
                        <list>javafx.geometry.Insets</list>
                        <list>javafx.scene.layout.VBox</list>
                        <list>javafx.scene.layout.HBox</list>
                        <list>javafx.scene.control.Button</list>
                        <list>javafx.scene.control.ScrollPane</list>
                        <list>javafx.scene.layout.GridPane</list>
                        <list>javafx.scene.layout.ColumnConstraints</list>
                        <list>javafx.scene.control.Label</list>
                        <list>javafx.scene.control.Tooltip</list>
                        <list>loliSnatcher.Booru</list>
                        <list>loliSnatcher.BooruHandler</list>
                        <list>loliSnatcher.BooruItem</list>
                        <list>loliSnatcher.Controller</list>
                        <list>loliSnatcher.DanbooruHandler</list>
                        <list>loliSnatcher.GelbooruHandler</list>
                        <list>loliSnatcher.ImageWindowController</list>
                        <list>loliSnatcher.ImageWriter</list>
                        <list>loliSnatcher.MoebooruHandler</list>
                        <list>loliSnatcher.SearchController</list>
                        <list>loliSnatcher.SettingsController</list>
                        <list>loliSnatcher.SnatcherController</list>
                        <list>loliSnatcher.WindowManager</list>
                    </reflectionList>
                    <mainClass>${mainClassName}</mainClass>
                </configuration>

            </plugin>
于 2020-02-03T11:55:41.030 回答