This is not very strange. You are trying to read a context from a file that does not exist.
True to its name, ClassPathXmlApplicationContext does not use the path as an absolute path, but it looks in the class path. You have to use
ApplicationContext context = new ClassPathXmlApplicationContext("/spring-cfg.xml");
NOTE: this will not read the file from src , but from the compiled classes (where it should have been copied at compile time).
source share