title: JAXB Marshalling a variable list of elements with the same name
body: <p>As per the title, I have an XML file I need to unmarshal:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;root&gt;
      &lt;wrap&gt;
          &lt;Element&gt;something1&lt;/Element&gt;
          &lt;Element&gt;something2&lt;/Element&gt;
          &lt;Element&gt;something3&lt;/Element&gt;
      &lt;/wrap&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>"wrap" is simply a wrapper, but the count of "element" varies.</p>
  
  <p>I have two classes to facilitate objects for JAXB:</p>
  
  <p>wrap class:</p>
  
  <pre><code>@XmlAccessorType(XmlAccessType.FIELD)
  @XmlRootElement(name = "root")
  public class Wrap {
      @XmlElementWrapper(name = "wrap")
      @XmlElement(name = "Element")
      private List&lt;Element&gt; elementList = new ArrayList&lt;&gt;();
  
      public Wrap() {}
  
      public Wrap(List&lt;Element&gt; list) {
          this.elementList = list;
      }
  
      public void addElement(Element element) {
          this.elementList.add(element);
      }
  
      public List&lt;Element&gt; getWrap() {
          return this.elementList;
      }
  
      public void setWrap(List&lt;Element&gt; wrap) {
          this.elementList = wrap;
      }
  }
  </code></pre>
  
  <p>element class:</p>
  
  <pre><code>@XmlRootElement(name = "Element")
  public class Element {
  
      private String Element;
  
      public Element() {}
  
      public Element(String element) {
          this.Element = element;
      }
  
      public String getElement() {
          return Element;
      }
  
      public void setElement(String element) {
          this.Element = element;
      }
  }
  </code></pre>
  
  <p>Attempting to unmarshal the XML completes without error, however, the element values are not stored with the element objects. Instead toString returns null for each of the objects.</p>
  
  <p>I did populate the objects with some data and marshal them to a file (shown below). This format, of course, is incorrect and should match the XML above.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;root&gt;
      &lt;wrap&gt;
          &lt;Element&gt;
              &lt;element&gt;entry1&lt;/element&gt;
          &lt;/Element&gt;
          &lt;Element&gt;
              &lt;element&gt;entry2&lt;/element&gt;
          &lt;/Element&gt;
          &lt;Element&gt;
              &lt;element&gt;entry3&lt;/element&gt;
          &lt;/Element&gt;
      &lt;/wrap&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I've researched this for awhile now with the assumptions my annotations are incorrect, but perhaps it's something else...</p>