我正在尝试组织我的项目,但是当我尝试加载控制器时,我得到了java.lang.reflect.InvocationTargetException
,但是我有正确的路径。我该如何解决?
<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">
错误
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
答案 0 :(得分:0)
好像您的问题不在路径中
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
问题是加载器未在控制器中找到方法handleAboutAction
尝试检查fxml和控制器中的方法名称拼写
我希望这能奏效(如果没有告诉我)
答案 1 :(得分:0)
您缺少Event
函数
@FXML
void handleAboutAction(ActionEvent event) {
}