title: Entry cannot be cast to javax.xml.bind.JAXBElement
body: <p>I keep getting the JAXB cast error.</p>
  
  <p>I'm not sure what to correct at this point.</p>
  
  <p>The unmarshalling:</p>
  
  <pre><code>try{
          Client client = Client.create();
          client.addFilter(new HTTPBasicAuthFilter(API_KEY, ""));
          WebResource webResource = client.resource("https://url.entries.xml");
          webResource.setProperty("", API_KEY);
          ClientResponse response = webResource.accept("application/xml").get(ClientResponse.class);
  
          if(response.getStatus() != 200){
              throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
          }
  
          String output = response.getEntity(String.class);
          System.out.println("\n============getFtoCResponse============");
          System.out.println(output);
  
  
          JAXBContext jaxbContext = JAXBContext.newInstance(Entries.class);
          Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  
          Entries itsEntries = (Entries)((JAXBElement)unmarshaller.unmarshal(new StringReader(output))).getValue();
  
  
      /*  Object o = unmarshaller.unmarshal(new StringReader(output));
          System.out.println(o.getClass());*/
  
      }catch(Exception e){
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Here are the first 16 lines from my Entry.java class, I have annotated setters and getters:</p>
  
  <pre><code>@XmlRootElement(name = "Entries")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Entry {
  
  
      private String DateCreated;
      private String EntryId;
      private String Field1;
  private String Field2;
  private String Field3;
  private String Field4;
  </code></pre>
  
  <p>And here is my Entries class, to be used to get a list of Entry objects:</p>
  
  <pre><code>@XmlRootElement(name = "Entries")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Entries extends Object {
  
      @XmlElement(name="Entries")
      private List&lt;Entry&gt; entryList = new ArrayList&lt;Entry&gt;();
  
      @XmlElement(name="Entries")
      public List&lt;Entry&gt; getEntryList() {
          return entryList;
      }
  
  
      public void setEntryList(List&lt;Entry&gt; entryList) {
          this.entryList = entryList;
      }
  
  }
  </code></pre>
  
  <p>Error Message:</p>
  
  <blockquote>
    <p>Entry cannot be cast to javax.xml.bind.JAXBElement</p>
  </blockquote>
  
  <p><strong>Question Update</strong></p>
  
  <p>Entries:</p>
  
  <pre><code>@XmlRootElement(name = "Entries")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class Entries {
  
      @XmlElement(name = "Entries")
      private List&lt;Entry&gt; entryList = new ArrayList&lt;Entry&gt;();
  
  
      public List&lt;Entry&gt; getEntryList() {
          return this.entryList;
      }
  
  
      public void setEntryList(List&lt;Entry&gt; entryList) {
          this.entryList = entryList;
      }
  
  }
  </code></pre>
  
  <p>Entry:</p>
  
  <p>@XmlAccessorType(XmlAccessType.FIELD)
  public class Entry {</p>
  
  <pre><code>private String DateCreated;
  private String EntryId;
  private String Field1;
  private String Field2;
  private String Field3;
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Entries&gt;
  &lt;Entry&gt;
  &lt;EntryId&gt;1&lt;/EntryId&gt;
  &lt;Field3&gt;John&lt;/Field3&gt;
  &lt;Field4&gt;Doe&lt;/Field4&gt;
  &lt;Field12&gt;21 jump street&lt;/Field12&gt;
  &lt;Field14&gt;&lt;/Field14&gt;
  &lt;Field15&gt;USA&lt;/Field15&gt;
  &lt;Field11&gt;USA&lt;/Field11&gt;
  &lt;/Entry&gt;
  &lt;/Entries&gt;
  </code></pre>