Tuesday

Spring - applicationContext.xml cannot be opened because it does not exist


BUG:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

private static final ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext.xml");

ClassA classA = (ClassA)factory.getBean("ClassA");

FIX:
You should keep your spring files in source folder. (src, resources vs.) WEB-INF is not a source folder.
Move your applicationContext.xml file in a sub-folder of the src folder.




java.lang.reflect.InvocationTargetException

InvocationTargetException means that the method you called threw an different exception.
To see the real exception details wrap the method with a try-catch block and log it.

Monday

Getting the name of the current executing method

public class Test {

       public static void main(String[] args) {
              lessTalkMoreCode1();
       }
      
       private static void lessTalkMoreCode1(){
              lessTalkMoreCode2();
       }
      
       private static void lessTalkMoreCode2(){
              lessTalkMoreCode3();
       }
      
       private static void lessTalkMoreCode3(){
              String className= Thread.currentThread().getStackTrace()[1].getClassName();
              System.out.println("Current executing class: " + className);
             
              System.out.println("Executing class list buttom up:");
              String method= Thread.currentThread().getStackTrace()[1].getMethodName();
              System.out.println(method);
      
              method= Thread.currentThread().getStackTrace()[2].getMethodName();
              System.out.println(method);
             
              method= Thread.currentThread().getStackTrace()[3].getMethodName();
              System.out.println(method);
             
              method= Thread.currentThread().getStackTrace()[4].getMethodName();
              System.out.println(method);
       }

}

output:
Current executing class: Test
Executing class list buttom up:
lessTalkMoreCode3
lessTalkMoreCode2
lessTalkMoreCode1
main


Where Eclipse workspace projects is stored?

Your projects are stored in the following directory:

Windows:
<workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\
Linux / osx:
<workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/