Q:

ClassPathXmlApplicationContext ERROR

import org.springframework.context. ApplicationContext;
import org.springframework.context.support. ClassPathXmlApplicationContext;

public class TestSpringProject {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig.xml");

        Restaraunt restaurantObj = (Restaraunt) context.getBean("restaurantBean");

        restaurantObj.greetCustomer();
    }
}

run:

Exception in thread "main" java.lang. NoClassDefFoundError: org/apache/commons/logging/LogFactory
      at org.springframework.context.support. AbstractApplicationContext.(AbstractApplicationContext.java:154)
      at org.springframework.context.support. AbstractApplicationContext.(AbstractApplicationContext.java:215)
      at org.springframework.context.support. AbstractRefreshableApplicationContext.(AbstractRefreshableApplicationContext.java:88)
      at org.springframework.context.support. AbstractRefreshableConfigApplicationContext.(AbstractRefreshableConfigApplicationContext.java:58)
      at org.springframework.context.support. AbstractXmlApplicationContext.(AbstractXmlApplicationContext.java:61)
      at org.springframework.context.support. ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:136)
      at org.springframework.context.support. ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
      at org.springcore.tutorials. TestSpringProject.main(TestSpringProject.java:8)
  Caused by: java.lang. ClassNotFoundException: org.apache.commons.logging. LogFactory
      at java.net. URLClassLoader$1.run(URLClassLoader.java:372)
      at java.net. URLClassLoader$1.run(URLClassLoader.java:361)
      at java.security. AccessController.doPrivileged(Native Method)
      at java.net. URLClassLoader.findClass(URLClassLoader.java:360)
      at java.lang. ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc. Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang. ClassLoader.loadClass(ClassLoader.java:357)
      ... 8 more
  Java Result: 1
  BUILD SUCCESSFUL (total time: 2 seconds)

A:

java.lang. ClassNotFoundException: org.apache.commons.logging. LogFactory at

You need apache commons logging jar in your project .  It is not able to resolve LogFactory in your project. 