使用 GraalVM、Maven、GluonFX 插件的本机图像 - 资源包问题 com.sun.glass.ui.win

Native image using GraalVM, Maven, GluonFX plugin - problem with resource bundle com.sun.glass.ui.win

GraalVM 版本:21.2.0 JavaFX 版本:17.0.0.1 Maven 版本:3.6.3

我非常接近 运行 我的原始图像,我在 pom.xml 等中将 类 添加到我的反射列表,但现在我正在努力由于未找到资源包错误而停止。如果有人能给我提示,那将不胜感激。

这是我的 pom.xml:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>MyProject-fxml.main</groupId>
    <artifactId>MyProject-fxml</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-base</artifactId>
            <version>17.0.0.1</version>
            <classifier>win</classifier>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.0.1</version>
            <classifier>win</classifier>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>17.0.0.1</version>
            <classifier>win</classifier>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17.0.0.1</version>
            <classifier>win</classifier>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>22.0.0</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>gluonfx-maven-plugin</artifactId>
                <version>1.0.6</version>
                <configuration>
                    <mainClass>com.MyProject.Main</mainClass>
                    <reflectionList>
                        <list>com.MyProject.MyProject</list>
                        <list>com.MyProject.controllers.MainViewController</list>
                        <list>com.MyProject.controllers.stagecontrollers.SimpleStageController</list>
                        <list>com.MyProject.model.helpers.AppPreferences</list>
                        <list>com.MyProject.model.helpers.ScreenResolution</list>
                        <list>javafx.scene.control.SplitPane</list>
                        <list>javafx.scene.layout.AnchorPane</list>
                    </reflectionList>
                    <resourcesList>com.sun.glass.ui.win</resourcesList>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.7</version>
                <configuration>
                    <mainClass>com.MyProject.Main</mainClass>
                </configuration>
            </plugin>

            <!-- TODO: Figure out how to make an executable jar with Maven -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix></classpathPrefix>
                            <mainClass>com.MyProject.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>run-java</id>
                        <phase>package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>com.MyProject.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

后面是错误输出:

[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] Oct 09, 2021 11:19:12 AM com.sun.javafx.application.PlatformImpl startup
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @2715644a'
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] Exception in Application start method
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] Oct 09, 2021 11:19:12 AM com.MyProject.APP show
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] SEVERE: There is an error launching the JavaFX runtime, or the application class cannot be constructed (e.g., if the class is not public or is not in an exported package), or an Exception or Error is thrown by the Application constructor, init method, start method, or stop method.java.lang.RuntimeException: Exception in Application start method
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] java.lang.RuntimeException: Exception in Application start method
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication(LauncherImpl.java:196)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.lang.Thread.run(Thread.java:829)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] Caused by: java.lang.ExceptionInInitializerError
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:315)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.lang.Class.ensureInitialized(DynamicHub.java:548)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(FXMLLoader.java:1020)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:757)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.MyProject.MyProject.loadMainViewParent(APP.java:88)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.MyProject.MyProject.start(APP.java:55)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1(LauncherImpl.java:847)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runAndWait(PlatformImpl.java:484)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:457)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.security.AccessController.doPrivileged(AccessController.java:105)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.lambda$runLater(PlatformImpl.java:456)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java:0)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.glass.ui.win.WinApplication.lambda$runLoop(WinApplication.java:184)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     ... 3 more
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB] Caused by: java.util.MissingResourceException: Can't find bundle for base name com/sun/glass/ui/win/themes, locale en_US
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2055)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1689)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1593)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1556)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at java.util.ResourceBundle.getBundle(ResourceBundle.java:857)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.glass.ui.win.WinApplication.getHighContrastScheme(WinApplication.java:344)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.glass.ui.win.WinApplication.getHighContrastTheme(WinApplication.java:350)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.tk.quantum.QuantumToolkit.getThemeName(QuantumToolkit.java:1809)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl._setPlatformUserAgentStylesheet(PlatformImpl.java:924)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:723)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.sun.javafx.application.PlatformImpl.setDefaultPlatformUserAgentStylesheet(PlatformImpl.java:687)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at javafx.scene.control.Control.<clinit>(Control.java:99)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
[Sat Oct 09 11:19:12 CEST 2021][INFO] [SUB]     ... 23 more
[Sat Oct 09 11:19:12 CEST 2021][SEVERE] Process run until end failed with result: 1

因此,缺少资源“com/sun/glass/ui/win/themes”。但是我找不到如何更正这个。

感谢 Jose Pereda,将上面的包添加到 <bundleslist/>gluonfx-maven-plugin 工作,即使 IntelliJ 没有显示此路径具有该名称的包。