title: Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader
body: <p>You might think that following issue is very simple, but I don't know what I did wrong here. I feel I added required dependencies. Haven't I?</p>
  
  <p>Could anyone please suggest me whats wrong here?</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      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)
      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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:242)
      at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
      at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
      at com.misc.common.ReadXMLFileJaxb.main(ReadXMLFileJaxb.java:14)
  Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader
      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)
      ... 23 more
  </code></pre>
  
  <p>Book.java</p>
  
  <pre><code>@XmlRootElement
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Book {
      @XmlAttribute
      private String firstName;
      @XmlElement
      private String lastName;
      @XmlElement
      private String age;
  
  
      public String getFirstName() {
          return firstName;
      }
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
      public String getLastName() {
          return lastName;
      }
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
      public String getAge() {
          return age;
      }
      public void setAge(String age) {
          this.age = age;
      }
      @Override
      public String toString() {
          return "Book [firstName=" + firstName + ", lastName=" + lastName+ ", age=" + age + "]";
      }
  }
  </code></pre>
  
  <p>ReadXMLFileJaxb.java</p>
  
  <pre><code>public class ReadXMLFileJaxb {
      public static void main(String[] args) {
          File file = new File(ReadXMLFileDOM.class.getClassLoader().getResource("book.xml").getFile());
  
          try {
              JAXBContext context = JAXBContext.newInstance(Book.class);
              Unmarshaller unmarshaller = context.createUnmarshaller();
              Book book = (Book) unmarshaller.unmarshal(file);
              System.out.println(book.toString());
          } catch (JAXBException e) {
              System.out.println(e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>My book.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;book&gt;
      &lt;person&gt;
          &lt;first&gt;Kiran&lt;/first&gt;
          &lt;last&gt;Pai&lt;/last&gt;
          &lt;age&gt;22&lt;/age&gt;
      &lt;/person&gt;
      &lt;person&gt;
          &lt;first&gt;Bill&lt;/first&gt;
          &lt;last&gt;Gates&lt;/last&gt;
          &lt;age&gt;46&lt;/age&gt;
      &lt;/person&gt;
      &lt;person&gt;
          &lt;first&gt;Steve&lt;/first&gt;
          &lt;last&gt;Jobs&lt;/last&gt;
          &lt;age&gt;40&lt;/age&gt;
      &lt;/person&gt;
  &lt;/book&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KeT8H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KeT8H.png" alt="enter image description here"></a></p>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;!-- JAXB --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2.11&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;
              &lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;
              &lt;version&gt;2.2.12&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>