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.
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();
}
}
Stack Trace After Adding Try-Catch in Start Method :
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)
{
bean_controller_Other_I.other_save_new_and_save_edit_other_word_button_action(actionEvent);
}
Snippet of FXML Code:
<Button layoutX="197.0" layoutY="32.0" mnemonicParsing="false" onAction="#other_save_new_and_save_edit_other_word_button_action" prefWidth="75.0" text="Save" AnchorPane.leftAnchor="197.0" />
Problem Identified :
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
{
ApplicationContext applicationContext = ApplicationContextSingleTon.getBean();
}
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
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean id="bean_DAO_e2b_Impl" class="com.vocubulary.e2b.DAO_e2b_Impl" ></bean>
<bean id="bean_Controller_e2b_Impl" class="com.vocubulary.e2b.Controller_e2b_Impl" >
<property name="bean_DAO_e2b_I" ref="bean_DAO_e2b_Impl"/>
</bean>
<bean id="bean_DAO_e2e_Impl" class="com.vocubulary.e2e.DAO_e2e_Impl" ></bean>
<bean id="bean_Controller_e2e_Impl" class="com.vocubulary.e2e.Controller_e2e_Impl" >
<property name="bean_DAO_e2e_I" ref="bean_DAO_e2e_Impl"/>
</bean>
<!--start : problem Area-->
<bean id="bean_DAO_Other_Impl" class="com.vocubulary.other.DAO_Other_Impl" ></bean>
<bean id="bean_Controller_other_Impl" class="com.vocubulary.other.Controller_Other_Impl" >
<property name="bean_DAO_Other_I" ref="bean_DAO_Other_Impl"/>
</bean>
<!--end : problem Area-->
</beans>
I think no need to describe codes as they are self explanatory. I have identified some xml codes as problem in the xml mapping file. I think finally i have identified the problem.
If i am keeping the codes active within the problem area in xml mapping file then the problem is happening. But if i am commenting those lines, the program is starting well.
And another problem is if those lines are active, within ApplicationContextSingleTon class, "AC_Line 3" is not being printed. Means the application is being halted at "AC_Line 2".
I think i have mapped the classes properly. As i am using Netbeans, if i do ctrl+clik on the class names, mapped in the problem area, Netbeans is taking me the class.
Now i have two Questions :
Why i am not getting full stack trace?
What is the wrong with those lines?