title: NoClassDefFoundError of com/fasterxml/jackson/databind/ObjectMapper with Maven
body: <p>This is a similar question as the one <a href="https://stackoverflow.com/q/26068128/3697757">here</a>, which is unfortunately unresolved yet.</p>
  <blockquote>
  <p>If you want to debug the code, here is the <a href="https://github.com/hackjutsu/StackOverflow-Maven-Jackson/tree/master" rel="noreferrer">GitHub repo</a>.</p>
  </blockquote>
  <p>I got the following <code>NoClassDefFoundError</code> for <code>ObjectMapper</code> though I have added the related dependency to Mave <code>pom.xml</code>.</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
      at demo.DemoMain.main(DemoMain.java:10)
  Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      ... 1 more
  </code></pre>
  <p>Here is the source code <code>DemoMain.java</code></p>
  <pre><code>package demo;
  
  import com.fasterxml.jackson.databind.ObjectMapper;
  
  public class DemoMain {
      public static void main(String[] args) {
          System.out.println(&quot;Start&quot;);
          ObjectMapper mapper = new ObjectMapper();
          System.out.println(&quot;End&quot;);
      }
  }
  </code></pre>
  <p>This is my <code>pom.xml</code></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;Demo&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
          &lt;version&gt;2.8.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
          &lt;version&gt;2.8.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;version&gt;2.8.3&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.0.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;index&gt;true&lt;/index&gt;
                      &lt;manifest&gt;
                          &lt;addClasspath&gt;true&lt;/addClasspath&gt;
                          &lt;mainClass&gt;demo.DemoMain&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I compile and run the app by</p>
  <pre><code>mvn clean install
  java -jar target/Demo-1.0-SNAPSHOT.jar
  </code></pre>