title: Java Unmarshal list of objects with a class wrapper with JAXB
body: <p>From an XQuery performed by BaseX server I get a result like that:</p>
  
  <pre><code>&lt;ProtocolloList&gt;
    &lt;protocollo&gt;
      &lt;numero&gt;1&lt;/numero&gt;
      &lt;data&gt;2014-06-23&lt;/data&gt;
      &lt;oggetto/&gt;
      &lt;destinatario/&gt;
      &lt;operatore/&gt;
    &lt;/protocollo&gt;
       ...
  &lt;/ProtocolloList&gt;
  </code></pre>
  
  <p>And I need to convert this result in a List of Protocollo objects with JAXB so that I can show them with JList. Thus, following one of the discussions <a href="https://stackoverflow.com/questions/10485002/java-unmarshal-list-of-objects-with-jaxb">here</a> I've declared the following classes:</p>
  
  <pre><code>import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "protocollo")
  public class Protocollo {
  
    private int numero;
    private String data;
    private String oggetto;
    private String destinatario;
    private String operatore;
  
    public Protocollo(String d, String o, String des, String op) {
      this.data = d;
      this.oggetto = o;
      this.destinatario = des;
      this.operatore = op;
    }
  
    public Protocollo() {
  
    }
  
    @XmlElement
    public int getNumero() {
        return numero;
    }
  
    public void setNumero(int numero) {
        this.numero = numero;
    }
  
    @XmlElement
    public String getData() {
        return data;
    }
  
    public void setData(String data) {
        this.data = data;
    }
  
    @XmlElement
    public String getOggetto() {
        return oggetto;
    }
  
    public void setOggetto(String oggetto) {
        this.oggetto = oggetto;
    }
  
    @XmlElement
    public String getDestinatario() {
        return destinatario;
    }
  
    public void setDestinatario(String destinatario) {
        this.destinatario = destinatario;
    }
  
    @XmlElement
    public String getOperatore() {
        return operatore;
    }
  
    public void setOperatore(String operatore) {
        this.operatore = operatore;
    }
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>import java.util.ArrayList;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlElementWrapper;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "ProtocolloList")
  public class ProtocolloList {
  
    @XmlElementWrapper(name = "ProtocolloList")
    @XmlElement(name = "protocollo")
    private ArrayList&lt;Protocollo&gt; ProtocolloList;
  
    public ArrayList&lt;Protocollo&gt; getProtocolloList() {
        return ProtocolloList;
    }
  
    public void setProtocolloList(ArrayList&lt;Protocollo&gt; protocolloList) {
        ProtocolloList = protocolloList;
    }
  }
  </code></pre>
  
  <p>and finally I execute the converion like that:</p>
  
  <pre><code>JAXBContext jaxbContext = JAXBContext.newInstance(Protocollo.class);
  Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
  StringReader reader = new StringReader(this.resultXML);
  protocolli = (ProtocolloList) unmarshaller.unmarshal(reader);
  </code></pre>
  
  <p>And I keep on getting this exception:</p>
  
  <pre><code>unexpected element (uri:"", local:"ProtocolloList"). Expected elements are &lt;{}protocollo&gt;
  </code></pre>
  
  <p>I suppose I'm making some mistakes with annotations.
  Can you help?</p>