title: ClassNotFoundException when creating new ClassPathXmlApplicationContext
body: <p>I'm getting through <a href="http://www.tutorialspoint.com/spring/spring_bean_scopes.htm" rel="nofollow">this</a> tutorial on Spring bean scopes. I set up everything by hand and then packaged it using maven. This is my project's structure:</p>
  
  <pre><code>.
  ├── pom.xml
  ├── src
  │   └── main
  │       ├── java
  │       │   └── hello
  │       │       ├── HelloWorld.java
  │       │       └── MainApp.java
  │       └── resources
  │           └── Beans.xml
  </code></pre>
  
  <p>HelloWorld.java:</p>
  
  <pre><code>package hello;
  
  public class HelloWorld {
  
      private String message;
  
      public void setMessage(String message) {
          this.message = message;
      }
  
      public String getMessage() {
          return message;
      }
  }
  </code></pre>
  
  <p>MainApp.java:</p>
  
  <pre><code>package hello;
  
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  public class MainApp {
  
      public static void main(String[] args) {
          ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
  
          HelloWorld objA = (HelloWorld) context.getBean("helloWorld");
  
          objA.setMessage("I'm object A");
          System.out.println("Your Message: " + objA.getMessage());
  
          HelloWorld objB = (HelloWorld) context.getBean("helloWorld");
          System.out.println("Your Message: " + objB.getMessage());
      }
  }
  </code></pre>
  
  <p>Beans.xml:
      </p>
  
  <pre><code>&lt;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"&gt;
  
      &lt;bean id="helloWorld" class="hello.HelloWorld" scope="singleton"&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;hello&lt;/groupId&gt;
      &lt;artifactId&gt;hello&lt;/artifactId&gt;
      &lt;version&gt;0.0.1&lt;/version&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Then I run the jar like so:</p>
  
  <pre><code>java -jar target/hello-0.0.1.jar 
  </code></pre>
  
  <p>And get this log:</p>
  
  <pre><code>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 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
      at java.lang.Thread.run(Thread.java:745)
  Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
      at org.springframework.context.support.AbstractApplicationContext.&lt;init&gt;(AbstractApplicationContext.java:158)
      at org.springframework.context.support.AbstractApplicationContext.&lt;init&gt;(AbstractApplicationContext.java:222)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.&lt;init&gt;(AbstractRefreshableApplicationContext.java:88)
      at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.&lt;init&gt;(AbstractRefreshableConfigApplicationContext.java:58)
      at org.springframework.context.support.AbstractXmlApplicationContext.&lt;init&gt;(AbstractXmlApplicationContext.java:61)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:136)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at hello.MainApp.main(MainApp.java:9)
      ... 6 more
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:166)
      at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:130)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 14 more
  </code></pre>
  
  <p>Can you please tell me, what I'm doing wrong?</p>