title: javax.xml.bind.UnmarshalException: unexpected element (uri:
body: <p>I am getting the following error when trying to convert xml response to java objects using jaxb</p>
  
  <pre><code>       javax.xml.bind.UnmarshalException: unexpected element (uri:"http://SOMETHING/doc/2006-03-01/", local:"Name"). Expected elements are &lt;{}Name&gt;,&lt;{}IsTruncated&gt;,&lt;{}MaxKeys&gt;,&lt;{}Contents&gt;,&lt;{}Prefix&gt;,&lt;{}Marker&gt;
  </code></pre>
  
  <p>Here is my XML :</p>
  
  <pre><code>       &lt;ListBucketResult xmlns="http://something/doc/2006-03-01/"&gt;
             &lt;Name&gt;test2&lt;/Name&gt;
              &lt;Prefix/&gt;
              &lt;Marker/&gt;
              &lt;MaxKeys&gt;3&lt;/MaxKeys&gt;
              &lt;IsTruncated&gt;false&lt;/IsTruncated&gt;
              &lt;Contents&gt;
                    &lt;Key&gt;metadata.xml&lt;/Key&gt;
                    &lt;LastModified&gt;2012-09-04T08:29:36.000Z&lt;/LastModified&gt;
                      &lt;ETag&gt;6b836fd43c402681506926b2248ec418&lt;/ETag&gt;
                      &lt;Size&gt;3258&lt;/Size&gt;
                     &lt;StorageClass&gt;STANDARD&lt;/StorageClass&gt;
               &lt;/Contents&gt;
            &lt;/ListBucketResult&gt;
  </code></pre>
  
  <p>And my java object classes are something like this</p>
  
  <pre><code>            @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "", propOrder = {
          "name",
          "prefix",
          "marker",
          "maxKeys",
          "isTruncated",
          "contents"
      })
      @XmlRootElement(name = "ListBucketResult")
      public class ListBucketResult {
  
  @XmlElement(name = "Name", required = true)
  protected String name;
  @XmlElement(name = "Prefix", required = true)
  protected String prefix;
  @XmlElement(name = "Marker", required = true)
  protected String marker;
  @XmlElement(name = "MaxKeys")
  protected int maxKeys;
  @XmlElement(name = "IsTruncated")
  protected boolean isTruncated;
  @XmlElement(name = "Contents", required = true)
  protected ListBucketResult.Contents contents;
  
  
  
  
  
  
  
           @XmlAccessorType(XmlAccessType.FIELD)
           @XmlType(name = "", propOrder = {
                  "key",
                  "lastModified",
                     "eTag",
                     "size",
                   "storageClass"
             })
            public static class Contents {
  
      @XmlElement(name = "Key", required = true)
      protected String key;
      @XmlElement(name = "LastModified", required = true)
      @XmlSchemaType(name = "dateTime")
      protected XMLGregorianCalendar lastModified;
      @XmlElement(name = "ETag", required = true)
      protected String eTag;
      @XmlElement(name = "Size")
      protected int size;
      @XmlElement(name = "StorageClass", required = true)
      protected String storageClass;
  </code></pre>
  
  <p>and finally my unmarshalling code is :</p>
  
  <pre><code>                          JAXBContext jc = JAXBContext.newInstance(ListBucketResult.class);
              Unmarshaller unmarshaller = jc.createUnmarshaller();
              unmarshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
                 JAXBElement element = (JAXBElement) unmarshaller.unmarshal (inputStream);
              ListBucketResult customer = (ListBucketResult) element.getValue();
  </code></pre>
  
  <p>Could someone please let me know what am i doing incorrect ?</p>