Exception in application start method java lang reflect invocationtargetexception javafx

Exception in Application start method in JavaFX Application

At the first glance the question may seems to be duplicated. I have done some searches in Google.But unfortunately none of the results dont match with me. I have given the questions link below. Exception in Application start method java.lang.reflect.InvocationTargetException JavaFX image transition JavaFX — Exception in Application start method? Exception in Application start method Exception in Application start method Exception in Application start method java.lang.reflect.InvocationTargetException Ok, Let come to my problem. I am using Netbeans and Spring for dependency injection. My code was working fine. I just added a new method and connected it with a button. After pressing the run button i have got the error. Stack Trace:

Executing C:\Users\Dell-3460\Documents\NetBeansProjects\JavaFXApplication_Vocubulary_Own\dist\run151098339\JavaFXApplication_Vocubulary_Own.jar using platform C:\Program Files\Java\jdk1.8.0_102\jre/bin/java Start1. Nov 23, 2017 10:30:52 PM javafx.fxml.FXMLLoader$ValueElement processValue WARNING: Loading FXML document with JavaFX API of version 8.0.141 by JavaFX runtime of version 8.0.102 Nov 23, 2017 10:30:53 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1d4f4e8e: startup date [Thu Nov 23 22:30:53 BDT 2017]; root of context hierarchy Nov 23, 2017 10:30:53 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [vocubularyBean.xml] Exception in Application start method 

From this StackTrace i am unable to trace the error. Then i have used Try-Catch within start method but no exact error message. Start Method :

@Override public void start(Stage stage) throws Exception < System.out.println("Start1. "); try < Parent root = FXMLLoader.load(getClass().getResource("FXML_Main.fxml")); System.out.println("Start2. "); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); >catch (Exception e) < e.printStackTrace(); >> 
Executing C:\Users\Dell-3460\Documents\NetBeansProjects\JavaFXApplication_Vocubulary_Own\dist\run151098339\JavaFXApplication_Vocubulary_Own.jar using platform C:\Program Files\Java\jdk1.8.0_102\jre/bin/java Start1. Nov 23, 2017 10:30:52 PM javafx.fxml.FXMLLoader$ValueElement processValue WARNING: Loading FXML document with JavaFX API of version 8.0.141 by JavaFX runtime of version 8.0.102 Nov 23, 2017 10:30:53 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1d4f4e8e: startup date [Thu Nov 23 22:30:53 BDT 2017]; root of context hierarchy Nov 23, 2017 10:30:53 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [vocubularyBean.xml] Exception in Application start method 

From this stack trace i am thinking there might some problems in FXML file as second line has not printed. But my question is why it is not showing any error message? I am using SceneBuilder. I have created an empty FXML file and it is loading. Snippet of Controller Code :

@FXML private void other_save_new_and_save_edit_other_word_button_action(ActionEvent actionEvent)
public class ApplicationContextSingleTon < private static ApplicationContext applicationContext ; public static ApplicationContext getBean() < System.out.println(" AC_Line 1 : "); if(applicationContext == null) < System.out.println(" AC_Line 2 : "); applicationContext = new ClassPathXmlApplicationContext("vocubularyBean.xml"); System.out.println(" AC_Line 3 : "); >return applicationContext; > > public interface ApplicationContext_I
public class Controller_Main implements Initializable,ApplicationContext_I < Controller_e2b_I bean_controller_e2b_I; Controller_e2e_I bean_controller_e2e_I; Controller_Other_I bean_controller_Other_I; @Override public void initialize(URL url, ResourceBundle rb) < bean_Initializer(); System.out.println(". Start. "); >public void bean_Initializer() < bean_controller_e2b_I = (Controller_e2b_I) applicationContext.getBean("bean_Controller_e2b_Impl"); bean_controller_e2b_I.setController_Main(this); bean_controller_e2e_I = (Controller_e2e_I) applicationContext.getBean("bean_Controller_e2e_Impl"); bean_controller_e2e_I.setController_Main(this); bean_controller_Other_I = (Controller_Other_I) applicationContext.getBean("bean_Controller_Other_Impl"); bean_controller_Other_I.setController_Main(this); >//other codes > 

Источник

Читайте также:  Python относительный путь модуля

JavaFX «Exception in Application start method»

package com.eit.main; /** * Created by PC on 19.03.2017. */ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.stage.Stage; import java.io.IOException; public class Main extends Application < private Stage primaryStage; public static void main(String[] args) < launch(args); >@Override public void start(Stage primaryStage) throws IOException < this.primaryStage = primaryStage; this.primaryStage.setTitle("Аппаратно-программный комплекс электроимпедансной томографии биологических объектов"); showMainView(); >private void showMainView() throws IOException < FXMLLoader loader = new FXMLLoader(); loader.setLocation(Main.class.getResource("/com.eit.main.view/MainView.fxml")); GridPane mainLayout = loader.load(); Scene scene = new Scene(mainLayout); primaryStage.setScene(scene); primaryStage.show(); >> 
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$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: Location is not set. at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) at com.eit.main.Main.showMainView(Main.java:30) at com.eit.main.Main.start(Main.java:24) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) . 1 more Exception running application com.eit.main.Main 

Источник

Exception in Application start method java.lang.reflect.InvocationTargetException

I am just starting out with JavaFX, and I am trying to build a simple application with a label, text field and button which, when clicked, sets the label’s value to that of the text field’s. Everything was going well until I connected the controller to the Main file. Here’s my code: Main.java

package application; import java.io.IOException; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.AnchorPane; public class Main extends Application < private Stage primaryStage; @Override public void start(Stage primaryStage) < this.primaryStage = primaryStage; // connect primary stage mainWindow(); >// main window public void mainWindow() < try < // view FXMLLoader loader = new FXMLLoader(Main.class.getResource("/MainWindowView.fxml")); AnchorPane pane = loader.load(); // controller MainWindowController mainWindowController = loader.getController(); mainWindowController.setMain(this); // scene on stage Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.show(); >catch (IOException e) < e.printStackTrace(); >> public static void main(String[] args) < launch(args); >> 
package application; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.TextField; public class MainWindowController < // views @FXML private Label label; @FXML private TextField field; private Main main; // connect main class to controller public void setMain(Main main) < this.main = main; >// assign text field text to label on button click public void handleButton() < String text = field.getText(); label.setText(text); field.clear(); >> 

I have tried multiple answers found on StackOverflow, but all that I have found were from 2 years ago and did not make any positive effect on my code. EDIT: Stack trace here:

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:497) 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:497) 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$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: Location is not set. at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) at application.Main.mainWindow(Main.java:27) at application.Main.start(Main.java:19) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) Exception running application application.Main 

Источник

Оцените статью