title: JAXB unmarshalling not working properly
body: <p>Im trying to use <code>JAXB</code> to Convert <strong>XML to Object</strong>, my XML look like this:</p>
  
  <pre><code>&lt;entityResource&gt;
     &lt;Item xsi:type="objectPermissionImpl"&gt;
        &lt;permissionMask&gt;0&lt;/permissionMask&gt;
        &lt;permissionRecipient xsi:type="roleImpl"&gt;
          &lt;externallyDefined&gt;false&lt;/externallyDefined&gt;
          &lt;roleName&gt;ROLE_USER&lt;/roleName&gt;
        &lt;/permissionRecipient&gt;
        &lt;URI&gt;repo:/public/adhoc/topics/JSDiagnosticTopic&lt;/URI&gt;
     &lt;/Item&gt;
     &lt;Item xsi:type="objectPermissionImpl"&gt;
        &lt;permissionMask&gt;0&lt;/permissionMask&gt;
        &lt;permissionRecipient xsi:type="roleImpl"&gt;
          &lt;externallyDefined&gt;false&lt;/externallyDefined&gt;
          &lt;roleName&gt;ROLE_ADMINISTRATOR&lt;/roleName&gt;
        &lt;/permissionRecipient&gt;
        &lt;URI&gt;repo:/public/adhoc/topics/JSDiagnosticTopic&lt;/URI&gt;
     &lt;/Item&gt;
  &lt;/entityResource&gt;
  </code></pre>
  
  <p>So i created 3 java classes : EntityResource.java, Item.java and PermissionRecipient.java as shown bellow:</p>
  
  <p><strong>EntityResource.java</strong></p>
  
  <pre><code>import java.util.List;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="entityResource")
  public class EntityResource {
  
      List&lt;Item&gt; ls_Item;
  
      public EntityResource() {
      }
  
      public List&lt;Item&gt; getLs_Item() {
          return ls_Item;
      }
  
      @XmlElement(name="Item")
      public void setLs_Item(List&lt;Item&gt; ls_Item) {
          this.ls_Item = ls_Item;
      }
  
      @Override
      public String toString() {
          return "EntityResource [ls_Item=" + ls_Item + "]";
      }
  
  }
  </code></pre>
  
  <p><strong>Item.java</strong></p>
  
  <pre><code>package model;
  
  import java.util.List;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="Item")
  public class Item {
  
      int permissionMask;
      List&lt;PermissionRecipient&gt; ls_permissionRecipient;
      String URI;
  
      public Item() {
  
      }
  
      public int getPermissionMask() {
          return permissionMask;
      }
  
      @XmlElement(name="permissionMask")
      public void setPermissionMask(int permissionMask) {
          this.permissionMask = permissionMask;
      }
  
      public List&lt;PermissionRecipient&gt; getLs_permissionRecipient() {
          return ls_permissionRecipient;
      }
  
      @XmlElement(name="permissionRecipient")
      public void setLs_permissionRecipient(
              List&lt;PermissionRecipient&gt; ls_permissionRecipient) {
          this.ls_permissionRecipient = ls_permissionRecipient;
      }
  
      public String getURI() {
          return URI;
      }
  
      @XmlElement(name="URI")
      public void setURI(String uRI) {
          URI = uRI;
      }
  
      @Override
      public String toString() {
          return "Item [permissionMask=" + permissionMask
                  + ", ls_permissionRecipient=" + ls_permissionRecipient
                  + ", URI=" + URI + "]";
      }
  
  
  
  
  
  }
  </code></pre>
  
  <p><strong>PermissionRecipient.java</strong></p>
  
  <pre><code>package model;
  
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name="permissionRecipient")
  public class PermissionRecipient {
  
      String roleName;
      boolean externallyDefined;
  
      public PermissionRecipient() {
  
      }
  
      public boolean isExternallyDefined() {
          return externallyDefined;
      }
  
      @XmlAttribute(name="externallyDefined")
      public void setExternallyDefined(boolean externallyDefined) {
          this.externallyDefined = externallyDefined;
      }
  
      public String getRoleName() {
          return roleName;
      }
  
      @XmlAttribute(name="roleName")
      public void setRoleName(String rolename) {
          this.roleName = rolename;
      }
  
      @Override
      public String toString() {
          return "PermissionRecipient [externallyDefined=" + externallyDefined
                  + ", roleName=" + roleName + "]";
      }
  
  
  }
  </code></pre>
  
  <p>All worked and i got an EntityResource object contain the Item but the permissionRecipient attribute of the Item attribute of EntityResource doesnt contain his attributes (roleName and externallyDefined) !</p>
  
  <p>My unmarshalling code is here:</p>
  
  <pre><code>JAXBContext jaxbContext = JAXBContext
                      .newInstance(EntityResource.class);
              Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
              EntityResource resourceDescriptors = (EntityResource) jaxbUnmarshaller
                      .unmarshal(conn.getInputStream());// conn is an HttpURLConnection
  </code></pre>
  
  <p>The <code>toString()</code> function of <strong>Item</strong> returned this results:</p>
  
  <pre><code>[Item 
  [permissionMask=0, 
  permissionRecipient=PermissionRecipient [externallyDefined=false, roleName=null], 
  URI=repo:/public/adhoc/topics/JSDiagnosticTopic], 
  
  Item 
  [permissionMask=0, 
  permissionRecipient=PermissionRecipient [externallyDefined=false, roleName=null], 
  URI=repo:/public/adhoc/topics/JSDiagnosticTopic]]
  </code></pre>
  
  <p>as u can mark, <code>[externallyDefined=false, roleName=null]</code> in each Item, why ? what mistake i have macked ? Thanks if anyone here can help me solve it, best regards.</p>