Reputation: 11
After hours of testing I still fail to run my JavaFX project as native app (.exe on Windows). I use JavaFX 11.0.2. I don't get any error when executing mvn clean gluonfx:build
. The errors come with mvn gluonfx:nativerun
:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Sep 02, 2021 12:13:03 AM com.sun.javafx.application.PlatformImpl startup
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @4a163575'
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] javafx.fxml.LoadException:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] fr/bullobily/fxml/Main.fxml:134
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB]
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.init(FxWindow.java:140)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<init>(FxWindow.java:116)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<clinit>(FxWindow.java:104)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.ChatApp.start(ChatApp.java:44)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java
:0)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:179)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.lang.Thread.run(Thread.java:829)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Caused by: java.lang.UnsupportedOperationException: Cannot determine type for property.
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.getSetterMethod(BeanAdapter.java:178)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:251)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:54)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.set(FXMLLoader.java:193)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:801)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] ... 20 more
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] javafx.fxml.LoadException:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] fr/bullobily/fxml/Chat.fxml:20
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB]
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.init(FxWindow.java:140)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<init>(FxWindow.java:116)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<clinit>(FxWindow.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.ChatApp.start(ChatApp.java:44)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java
:0)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:179)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.lang.Thread.run(Thread.java:829)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Caused by: com.sun.javafx.fxml.PropertyNotFoundException: Property "cacheShape" does not exist or is read-only.
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processValue(FXMLLoader.java:358)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:335)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:245)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:778)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] ... 20 more
Here are my Main.fxml and Chat.fxml (created with Scene Builder):
Main.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.geometry.Rectangle2D?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.paint.Color?>
<?import javafx.scene.paint.LinearGradient?>
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.text.Font?>
<Scene xmlns="%javafx.fx" xmlns:fx="%javafx.fxml" fx:controller="fr.bullobily.controller.MainController">
<AnchorPane prefHeight="387.0" prefWidth="559.0">
<children>
<HBox layoutX="274.0" layoutY="120.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox minWidth="-Infinity" prefHeight="387.0" prefWidth="211.0" style="-fx-background-color: #1DB6B1;" stylesheets="@../css/Main.css" HBox.hgrow="NEVER">
<children>
<Pane prefHeight="91.0" prefWidth="170.0">
<children>
<ImageView fitHeight="50.0" fitWidth="50.0" layoutY="18.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/app_icon.png" />
</image>
</ImageView>
<Label layoutX="56.0" prefHeight="86.0" prefWidth="111.0" text="Ma super appli de chat" wrapText="true">
<font>
<Font name="Candara Light" size="19.0" />
</font>
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
<Stop>
<color>
<Color red="0.8526315689086914" green="0.028421051800251007" blue="0.028421051800251007" />
</color>
</Stop>
<Stop offset="1.0">
<color>
<Color green="0.03805406019091606" blue="1.0" />
</color>
</Stop>
</stops>
</LinearGradient>
</textFill>
</Label>
</children>
</Pane>
<VBox prefHeight="149.0" prefWidth="213.0">
<children>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="132.79999542236328" minWidth="10.0" prefWidth="119.40001220703125" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="101.59999542236329" minWidth="10.0" prefWidth="71.39998779296876" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label prefWidth="114.0" text="Nom d'utilisateur :" />
<Label text="Personnes en ligne :" GridPane.rowIndex="1" />
<Label fx:id="usernameLab" text="Label" GridPane.columnIndex="1" />
<Label fx:id="onlineUsersCount" prefWidth="28.0" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
</children>
</GridPane>
<Button mnemonicParsing="false" onAction="#onConnectButton" prefWidth="1000.0" text="Connexion">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/connection.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
<padding>
<Insets bottom="20.0" top="20.0" />
</padding>
</VBox>
<VBox fx:id="buttonsVbox" prefHeight="0.0" prefWidth="170.0" spacing="20.0">
<children>
<Button mnemonicParsing="false" onAction="#onButtonChat" prefWidth="1000.0" text="Chat" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets />
</VBox.margin>
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/chat.png" />
</image>
<viewport>
<Rectangle2D />
</viewport>
</ImageView>
</graphic>
</Button>
<Button mnemonicParsing="false" onAction="#onButtonParameters" prefWidth="1000.0" text="Paramètres">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/picture.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
<VBox.margin>
<Insets bottom="20.0" />
</VBox.margin>
<padding>
<Insets bottom="20.0" top="20.0" />
</padding>
</VBox>
</children>
<padding>
<Insets left="10.0" right="10.0" />
</padding>
</VBox>
<AnchorPane fx:id="contentPane" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</AnchorPane>
</Scene>
Chat.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" cacheShape="false" centerShape="false" nodeOrientation="RIGHT_TO_LEFT" prefHeight="306.0"
prefWidth="329.0" scaleShape="false" spacing="21.0" xmlns="%javafx.fx" xmlns:fx="%javafx.fxml"
fx:controller="fr.bullobily.controller.ChatController">
<padding>
<Insets bottom="30.0" left="30.0" right="30.0" top="30.0"/>
</padding>
<ListView fx:id="chatList" prefHeight="530.0" prefWidth="539.0"/>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="8.0">
<TextField fx:id="textSelectionField" prefWidth="539.0"/>
<Button mnemonicParsing="false" onAction="#sendToChat" text="Envoyer"/>
</VBox>
</VBox>
And finally my src/main/resources/META-INF/substrate/config/reflectionconfig.json
, which (is supposed to) contain all classes and methods I use in my fxml files: https://pastebin.com/EqQpBiKH
My code works well when running in IntelliJ but not from native image. I exhausted all the possibilities of resolution that I had imagined...
Upvotes: 0
Views: 544
Reputation: 65
@JoséPereda beat me to this but I'll still share an alternative solution that's been working for me.
Rather than stepping through your app's screens (and sub-screens) using gluonfx:runagent, you can just add the classes in question to your pom.xml.
Your stacktrace complains about not knowing the property "cacheShape". It's a field from type Region which many sub-classes inherit from. Your Chat.fxml line number referenced points to the VBox element. So, you add that java class to your pom as so:
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>${gluonfx.plugin.version}</version>
<configuration>
<reflectionList>
<list>javafx.scene.layout.VBox</list>
Now, you won't get that runtime error again. If you make new UI Views that also use VBox, you still won't run into this error again, as long as the class is still listed in your pom file.
Your Main.fxml also complained, pointing to AnchorPane element. If that also is still a runtime error, just update your list of classes in the pom again as so:
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>${gluonfx.plugin.version}</version>
<configuration>
<reflectionList>
<list>javafx.scene.layout.VBox</list>
<list>javafx.scene.layout.AnchorPane</list>
My list of classes in my project's pom is getting lengthy as I continue developing views and features, but I prefer addressing each such issue once in the pom than repeatedly running gluonfx:runagent and manually stepping through my app's UI.
Upvotes: 1