FXML Datei in Java Code einbinden: javafx.fxml.LoadException

tm.grp1

Neues Mitglied
Hallo,
ich arbeite momentan an einem kleinen Java Projekt für die Uni, dafür muss ich nun auch eine GUI in Form einer .fxml Datei einbinden. Ich habe damit leider gar keine Erfahrung und stecke nun fest, ich konnte die GUI mit SceneBuilder erstellen und dann auch erfolgreich einbinden und starten. Dann habe ich angefangen die Buttons und ListViewer im Controller und der .fxml Datei zu verknüpfen. Ich habe das für die erste Seite meines GUIs gemacht, wollte es dann testen, seitdem wird mir eine javafx.fxml.LoadException geworfen. Habe erst gedacht es müsste an den verschiedenen Versionen von JavaFX und dem fxml Dokument liegen, allerdings macht das ja auch nicht wirklich Sinn, da ich die GUI ja ohne Elemente verknüpft zu haben, einwandfrei starten konnte. Da ich ansonsten aus der Fehlermeldung leider nicht so wirklich schlau werde, wollte ich die Fehlermeldung hier mal rein posten, in der Hoffnung das sich evtl. jemand findet der damit mehr anfangen kann als ich.

Vielen Dank schon mal für eure Rückmeldungen!

Java:
> Task :GuiLauncher.main() FAILED
Sep. 16, 2021 6:13:42 NACHM. javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 16 by JavaFX runtime of version 12.0.1
Exception in Application start method
Loading FXML document with JavaFX API of version 16 by JavaFX runtime of version 12.0.1

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.base/java.lang.Thread.run(Thread.java:834)
Caused by: javafx.fxml.LoadException:
Caused by: javafx.fxml.LoadException:

/C:/Users/timgr/IdeaProjects/Mensabot1_3/build/resources/main/de/uniwue/jpp/mensabot/gui/GUI.fxml

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2603)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
    at de.uniwue.jpp.mensabot.gui.MensabotGui.start(MensabotGui.java:16)
    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.base/java.security.AccessController.doPrivileged(Native Method)
    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.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more
Caused by: java.lang.UnsupportedOperationException
Caused by: java.lang.UnsupportedOperationException

    at de.uniwue.jpp.mensabot.sending.formatting.Formatter.createShortFormatter(Formatter.java:84)
    at de.uniwue.jpp.mensabot.gui.Controller.initialize(Controller.java:25)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2573)
    ... 17 more

Execution failed for task ':GuiLauncher.main()'.
> Process 'command 'C:/Program Files/Java/jdk-11.0.10/bin/java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
 
Wenn man den Stacktrace durcharbeitet landet man bei:
Java:
Caused by: java.lang.UnsupportedOperationException
    at de.uniwue.jpp.mensabot.sending.formatting.Formatter.createShortFormatter(Formatter.java:84)
    at de.uniwue.jpp.mensabot.gui.Controller.initialize(Controller.java:25)

Guck dir mal deinen Code in der Klasse Formatter in Zeile 84 an 🙂
 
Vielen Dank für deine schnelle Rückmeldung. War ein super Tipp den Formatter mal anzusehen 🙂. Ich hatte nämlich testhalber in der initialize Methode des Controllers zwei Methoden an ein ListView übergeben, in Zeile 84 konnte ich dann herausfinden das eine der beiden Methoden noch nicht vollständig implementiert war und daher eine UnsupportedOperationException geworfen hat.
 

Zurück
Oben