title: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"TestSubject"). Expected elements are <{}Test>
body: <p>There are  several help topics concerning the issue 
  but I haven't found a solution that solved my issue.
  I appreciate guidance in solving the issue.</p>
  
  <p>I tried generating xml thru Marshal and below xml is what is generated from code.</p>
  
  <p>I have to work with xml structure below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;Test&gt;
      &lt;testSubject&gt;
          &lt;firstName&gt;test1&lt;/firstName&gt;`enter code here`
          &lt;lastNAme&gt;lastname&lt;/lastNAme&gt;
          &lt;ssn&gt;123456&lt;/ssn&gt;
      &lt;/testSubject&gt;
  &lt;/Test&gt;
  </code></pre>
  
  <p>code</p>
  
  <pre><code>@XmlRootElement(name = "Test")
  public class Test { 
        public Test()
        {
            testSubject = new ArrayList&lt;TestSubject&gt;();
        }
  
      List&lt;TestSubject&gt; testSubject;
  
      @XmlElement(name = "testSubject", type = TestSubject.class)         
      public List&lt;TestSubject&gt; getTestSubject() {
          return testSubject;
      }
  
      public void setTestSubject(List&lt;TestSubject&gt; testSubject) {
          this.testSubject = testSubject;
      }
  </code></pre>
  
  <p>TestSubject class</p>
  
  <pre><code>public class TestSubject {
  
      String firstName;
      String lastNAme;
      int ssn;
  
  //getters and setters
  
  }
  </code></pre>
  
  <p><strong>//unmarshall code in my main class</strong></p>
  
  <pre><code>JAXBContext jc = JAXBContext.newInstance(Test.class);
  
  Unmarshaller unmarshaller = jc.createUnmarshaller();
  File xml = new File("c://testSubjects.xml");
  Test tests = (Test) unmarshaller.unmarshal(xml);
  </code></pre>
  
  <p><em><strong>Exception</em></strong></p>
  
  <pre><code>javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"TestSubject"). Expected elements are &lt;{}Test&gt;
      at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:662)
  </code></pre>