title: ClassNotFoundException: org.springframework.context.support.ClassPathXmlApplicationContext
body: <p>i am working on a <strong>standalone application</strong> build with <strong>maven</strong>, and i add the <strong>dependencies</strong> to the <strong>target jar</strong> in a <strong>lib folder</strong> using <strong>maven-dependency-plugin</strong> with <strong>maven-assembly-plugin</strong> the application runs fine from eclipse with no problems, but when trying to run the generated jar file from command line, i am getting following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext
          at com.spring.sample.MainClass.main(MainClass.java:11)
  Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.ClassPathXmlApplicationContext
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          ... 1 more
  </code></pre>
  
  <p>i looked inside the generated jar lib folder, and i found that the <strong>spring-context-support.jar</strong> is already there, so i am wondering why i am getting such exception.</p>
  
  <p>here's my <strong>maven build configuration</strong>:</p>
  
  <pre><code>&lt;build&gt;
  
    &lt;resources&gt;
  
              &lt;resource&gt;
                  &lt;directory&gt;src/main/resources&lt;/directory&gt;
                  &lt;filtering&gt;true&lt;/filtering&gt;
              &lt;/resource&gt;
  
    &lt;/resources&gt;
  
        &lt;plugins&gt;
  
  
            &lt;plugin&gt; 
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-dependencies&lt;/id&gt;
                      &lt;phase&gt;prepare-package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy-dependencies&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;${project.build.directory}/classes/lib&lt;/outputDirectory&gt;                       
                          &lt;overWriteReleases&gt;false&lt;/overWriteReleases&gt;
                          &lt;overWriteSnapshots&gt;false&lt;/overWriteSnapshots&gt;
                          &lt;overWriteIfNewer&gt;true&lt;/overWriteIfNewer&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;classpathPrefix&gt;lib/&lt;/classpathPrefix&gt;
                          &lt;mainClass&gt;com.myapp.MainClass&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.6&lt;/source&gt;
                      &lt;target&gt;1.6&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;install&lt;/id&gt;
                          &lt;phase&gt;install&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;sources&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                 &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
                 &lt;version&gt;2.5&lt;/version&gt;
                 &lt;configuration&gt;
                 &lt;encoding&gt;UTF-8&lt;/encoding&gt;
                 &lt;/configuration&gt;
              &lt;/plugin&gt;
  
  
             &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;create-my-bundle&lt;/id&gt;
                                  &lt;phase&gt;package&lt;/phase&gt;
                                      &lt;goals&gt;
                                          &lt;goal&gt;single&lt;/goal&gt;
                                      &lt;/goals&gt;
                           &lt;configuration&gt;
                             &lt;descriptorRefs&gt;
                              &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                             &lt;/descriptorRefs&gt;
  
                           &lt;/configuration&gt;
                          &lt;/execution&gt;
                     &lt;/executions&gt;
  
              &lt;/plugin&gt; 
  
  
        &lt;/plugins&gt;
    &lt;/build&gt;
  </code></pre>