title: java.lang.NoClassDefFoundError: org/springframework/core/io/Resource Exception
body: <p>I am very new to both Spring and maven. I am getting an error. I am using Maven from command line to build the project.</p>
  
  <p>I have updated spring-core and spring-context dependencies, after that I have done <code>mvn clean install</code> and it says no problem. I did <code>mvn eclipse:eclipse</code> after it and it also went fine. I compile with <code>mvn clean compile</code> and that passes too. I have checked in .m2 folder ( on MacOS) that yes spring-core is there. Yet while running my project, this run time exception is coming; I have tried several other solutions given on Stack Overflow but none of them worked. </p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
  
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
          at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
          at java.lang.Class.getMethod0(Class.java:3018)
          at java.lang.Class.getMethod(Class.java:1784)
          at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
      Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.Resource
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 7 more
  </code></pre>
  
  <p>This is my POM file.</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;Spring_1&lt;/groupId&gt;
    &lt;artifactId&gt;SpringCIList&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
    &lt;name&gt;SpringCIList&lt;/name&gt;
    &lt;!-- FIXME change it to the project's website --&gt;
    &lt;url&gt;http://www.example.com&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;maven.compiler.source&gt;1.7&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.7&lt;/maven.compiler.target&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;version&gt;4.2.6.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;4.2.6.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  
     &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.11&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  
    &lt;build&gt;
      &lt;pluginManagement&gt;&lt;!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --&gt;
        &lt;plugins&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.7.0&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.20.1&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
            &lt;version&gt;3.0.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-install-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.5.2&lt;/version&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
            &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.8.2&lt;/version&gt;
          &lt;/plugin&gt;
        &lt;/plugins&gt;
      &lt;/pluginManagement&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>One quick doubt from my side, could this ( beans -2.5 xsd)</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-2.5.xsd"&gt;
  </code></pre>
  
  <p>be the problem-root??</p>
  
  <p>Edit 1 Exact run command which is causing exception to occur</p>
  
  <pre><code>.
  
  Rishis-MBP:SpringCIList rishiprakash$ cd target/classes/
  Rishis-MBP:classes rishiprakash$ ls
  Spring_1        spring-module.xml
  Rishis-MBP:classes rishiprakash$ java Spring_1.App
  Error: A JNI error has occurred, please check your installation and try again
  Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
      at java.lang.Class.getDeclaredMethods0(Native Method)......
  </code></pre>
  
  <p>App.java</p>
  
  <pre><code>package Spring_1;
  
  import org.springframework.beans.factory.BeanFactory;
  import org.springframework.beans.factory.xml.XmlBeanFactory;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.core.io.Resource;
  
  public class App
  {
  
      public static void main( String[] args )
      {
  
  Resource r = new ClassPathResource("spring-module.xml");
  BeanFactory factory = new XmlBeanFactory(r);
  Employee e = (Employee)factory.getBean("emp");
          System.out.println( "Hello World!" );
          e.displayInfo();
  
  
  
      }
  }
  </code></pre>
  
  <p>Employee.java</p>
  
  <pre><code>package Spring_1;
  
  class Employee{
  
  private  String name;
  
  String getName(){
  return this.name;
  }
  void setName(String name){
  this.name = name;
  }
  
  void displayInfo(){
    System.out.println("name of employee is"+this.name);
  }
  
  
  }
  </code></pre>
  
  <p>spring-module.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-2.5.xsd"&gt;
  
  &lt;bean id="emp" class="Spring_1.Employee"&gt;
  &lt;property name="name" value="Rishi"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  
  
    &lt;/beans&gt;
  </code></pre>
  
  <p>Same project when imported to eclipse (with m2e plugin) is working.</p>