title: Unexpected element (uri:"", local: "element"). Expected elements are <{}link> <{}size>
body: <p>When trying to unmarshall this xml:</p>
  
  <pre><code>&lt;holder&gt;
    &lt;name&gt;a&lt;/name&gt;
    &lt;elements&gt;
      &lt;element&gt;
        &lt;name&gt;elem&lt;/name&gt;
      &lt;/element&gt;
    &lt;/elements&gt;
  &lt;/holder&gt;
  </code></pre>
  
  <p>I get the error <code>unexpected element (uri:"", local:"element"). Expected elements are &lt;{}link&gt;,&lt;{}totalSize&gt;</code> in the <code>ValidationEventHandler</code> and the tag <code>&lt;elements&gt;</code> (and therefore the <code>elements</code> field in <code>Holder</code> class) is ignored.</p>
  
  <p>When generating the <code>XML</code> both <code>link</code> and <code>totalSize</code> are not outputted as they are nil.</p>
  
  <p><strong>JAVA MODEL</strong></p>
  
  <p>The hierarchy is a bit complex:</p>
  
  <p>(Simplified for the sake of the question)</p>
  
  <p><strong>ElementRoot</strong></p>
  
  <p>abstract <code>ElementRoot</code> has the link member</p>
  
  <pre><code>public abstract class ElementRoot implements Serializable {
  
      protected String link;
  
      @XmlElement(name = "link")
      public String getLink() {
          return link;
      }
  
      public void setLink(String link) {
          this.link = link;
      }
  
  }
  </code></pre>
  
  <p><strong>Wrapper</strong></p>
  
  <p>abstract Wrapper extends ElementRoot and has the totalSize member</p>
  
  <pre><code>public abstract class Wrapper&lt;T&gt; extends ElementRoot {
  
      protected int totalSize;
  
      protected List&lt;T&gt; collection = new ArrayList&lt;&gt;();
  
      @XmlElement
      public int getTotalSize() {
          return totalSize;
      }
  
      public void setTotalSize(int totalSize) {
          this.totalSize = totalSize;
      }
  
      public abstract List&lt;T&gt; getCollection();
  }
  </code></pre>
  
  <p><strong>Holder</strong></p>
  
  <p>Holder extends ElementRoot</p>
  
  <pre><code>@XmlRootElement(name = "holder")
  @XmlType(propOrder = {"name", "elements"})
  public class Holder extends ElementRoot {
  
      private String name;
  
      private Elements elements;
  
      // setters and getters not annotated
  }
  </code></pre>
  
  <p><strong>Elements</strong></p>
  
  <p>Elements extends Wrapper and has a collection of Element</p>
  
  <pre><code>import java.util.Collection;
  import javax.xml.bind.annotation.*;
  
  @XmlRootElement(name = "elements)
  public class Elements extends Wrapper {
  
      @Override
      @XmlElement(name="element")
      public Collection&lt;Element&gt; getElements() {
          return elements;
      }
  
      // No setter, to add getElements().add(element)
  }
  </code></pre>
  
  <p><strong>Element</strong></p>
  
  <p>Element extends ElementRoot</p>
  
  <pre><code>@XmlRootElement(name = "element")
  @XmlType(propOrder = {"id", "name"})
  public class Element extends ElementRoot {
  
       private Integer id;
  
       private String name;
  
       // setters and getters no annotated
  
  }
  </code></pre>
  
  <p><strong>ENVIRONMENT</strong></p>
  
  <p>I'm using <code>java 7</code>:</p>
  
  <pre><code>JAXB-api 2.2.7
  MOXy 2.5.0
  </code></pre>