0

I am trying to organize my project , but when I try to load my controller , and I got java.lang.reflect.InvocationTargetException but I have the right path. how can I fix this?

<AnchorPane id="AnchorPane" prefHeight="570.0" prefWidth="784.0" styleClass="root" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="user.ui.main.StrixController">

error

file:/home/xxxx/NetBeansProjects/strixx/dist/run385118534/xxxx.jar!/user/ui/main/strix.fxml:10

treeview

├── resources
│   ├── images
│   │   ├── 156081805144861603.png
│   │   └── icon
│   │       ├── blueGlass.png
│   │       ├── exploit.png
│   │       ├── icon.png
│   │       └── shaker.png
│   └── theme
│       └── dark.theme.css
├── strix
│   └── ui
│       ├── about
│       │   ├── aboutController.java
│       │   └── about.fxml
│       └── main
│           ├── StrixController.java
│           ├── strix.fxml
│           └── Strix.java
└── util
    └── strixUtil.java

Executing /home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar using platform /usr/lib/jvm/java-8-oracle/jre/bin/java
Gtk-Message: 00:24:34.842: Failed to load module "pantheon-filechooser-module"

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",

(java:17030): Gtk-WARNING **: 00:24:34.848: Unable to locate theme engine in module_path: "pixmap",
Gtk-Message: 00:24:34.849: Failed to load module "canberra-gtk-module"
Exception in Application start method
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$412(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleAboutAction', either the event handler is not in the Namespace or there is an error in the script.
file:/home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar!/javafxapplication11/ui/main/FXMLDocument.fxml:26

    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2597)
    at javafx.fxml.FXMLLoader.access$100(FXMLLoader.java:103)
    at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:610)
    at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:770)
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2823)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
    at javafxapplication11.ui.main.JavaFXApplication11.start(JavaFXApplication11.java:22)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$419(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$399(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$397(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$398(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$203(GtkApplication.java:139)
    ... 1 more
Exception running application javafxapplication11.ui.main.JavaFXApplication11
Java Result: 1
Store LTE
  • 11
  • 6
  • Please [edit] your question to include the entire [stack trace](https://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors). – Slaw Jun 18 '19 at 05:41
  • In your code above you wrote `fx:controller="user.ui.main.StrixController"` while the file listing there is no `user` package, just `strix`... – Usagi Miyamoto Jun 18 '19 at 06:29
  • The last `Caused by` in the stack trace is usually the real cause of the problem and according to your post, the relevant error message is `Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleAboutAction', either the event handler is not in the Namespace or there is an error in the script.` And the next line in the stack trace tells you which file and which line in that file, i.e. `file:/home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar!/javafxapplication11/ui/main/FXMLDocument.fxml:26` Looks like you are using Java 11. – Abra Jun 18 '19 at 06:34
  • As mentioned by Abra, the ultimate cause of the error is: "_Error resolving onAction='#handleAboutAction', either the event handler is not in the Namespace or there is an error in the script_". Please show the relevant controller class—either the `handleAboutAction` method is missing or you made a mistake configuring it. – Slaw Jun 18 '19 at 06:44

2 Answers2

0

Looks like your problem is not in the path

Caused by: javafx.fxml.LoadException: Error resolving onAction='#handleAboutAction', either 
the event handler is not in the Namespace or there is an error in the script.
file:/home/blackleitus/NetBeansProjects/JavaFXApplication11/dist/run981614013/JavaFXApplication11.jar!/javafxapplication11/ui/main/FXMLDocument.fxml:26

the problem is that the loader is not finding the method handleAboutAction in the controller try checking the method name spelling in the fxml and in the controller

I Hope this works (tell me if not)

Ibraheem Alyan
  • 426
  • 1
  • 5
  • 14
0

Your are missing the Event Function

   @FXML
    void handleAboutAction(ActionEvent event) {

    }
Raw
  • 461
  • 7
  • 15