title: java jaxb simple parsing is requiring @XmlAccessorType(XmlAccessType.FIELD) annotation
body: <p>I am trying to parse an xml to java objects, I've read and implemented the following tutorial:</p>
  
  <p><strong><a href="http://www.vogella.com/articles/JAXB/article.html" rel="nofollow">http://www.vogella.com/articles/JAXB/article.html</a> (works perfectly)</strong></p>
  
  <p>But when I create my own clases (similar to those in the tutorial)</p>
  
  <p>I get: Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
  <strong>Class has two properties of the same name "clienteList"</strong> </p>
  
  <p>Unless I use @XmlAccessorType(XmlAccessType.FIELD) on class Clientes but in the tutorial is not being used. </p>
  
  <p>Any ideas ?</p>
  
  <p>(It works fine with the @XmlAccessorType(XmlAccessType.FIELD) annotation but I want to know why is it being required with my classes while it is not for the classes in the tutorial)</p>
  
  <p>Thank you in advance for any information.</p>
  
  <p>Class Cliente</p>
  
  <pre><code>package mx.com.findep.crediseguros.dto.servicios.finsol;
  
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "cliente")
  public class Cliente {
  
    private String numeroPersona;
  
    @XmlElement(name = "numeroPersona")
    public String getNumeroPersona() {
      return numeroPersona;
    }
  
    public void setNumeroPersona(String numeroPersona) {
      this.numeroPersona = numeroPersona;
    }
  
  } 
  </code></pre>
  
  <p>Class Clientes</p>
  
  <pre><code>package mx.com.findep.crediseguros.dto.servicios.finsol;
  
  import java.util.ArrayList;
  
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlElementWrapper;
  import javax.xml.bind.annotation.XmlRootElement;
  
  @XmlRootElement(name = "clientes")
  //@XmlAccessorType(XmlAccessType.FIELD) //without this line it fails
  public class Clientes {
  
        // XmLElementWrapper generates a wrapper element around XML representation
        @XmlElementWrapper(name = "clienteList")
        // XmlElement sets the name of the entities
        @XmlElement(name = "cliente")
        private ArrayList&lt;Cliente&gt; clienteList;
  
  
        public void setClienteList(ArrayList&lt;Cliente&gt; clienteList) {
          this.clienteList = clienteList;
        }
  
        public ArrayList&lt;Cliente&gt; getClienteList() {
          return clienteList;
        }
  
  
      }
  </code></pre>
  
  <p>Testing My Marshalling</p>
  
  <pre><code>package mx.com.findep.crediseguros.dto.servicios.finsol;
  
  import java.io.File;
  import java.io.FileReader;
  import java.io.IOException;
  import java.util.ArrayList;
  
  import javax.xml.bind.JAXBContext;
  import javax.xml.bind.JAXBException;
  import javax.xml.bind.Marshaller;
  import javax.xml.bind.Unmarshaller;
  
  
  public class TestClientesXml {
  
    private static final String SOME_XML = "C:/bea/user_projects/domains/DominioDesarrollo/esquemas/calculoCostoSeguroPeticion.xml";
  
    public static void main(String[] args) throws JAXBException, IOException {
  
      ArrayList&lt;Cliente&gt; clienteList = new ArrayList&lt;Cliente&gt;();
  
      Cliente cliente1 = new Cliente();
      cliente1.setNumeroPersona("1");
  
      clienteList.add(cliente1);
  
      Cliente cliente2 = new Cliente();
      cliente2.setNumeroPersona("2");
      clienteList.add(cliente2);
  
      Clientes clientes = new Clientes();
  
      clientes.setClienteList(clienteList);
  
      JAXBContext context = JAXBContext.newInstance(Clientes.class);
      Marshaller m = context.createMarshaller();
      m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
  
      m.marshal(clientes, System.out);
  
      m.marshal(clientes, new File(SOME_XML));
  
      System.out.println();
      System.out.println("Output from our XML File: ");
      Unmarshaller um = context.createUnmarshaller();
      Clientes clientes2 = (Clientes) um.unmarshal(new FileReader(SOME_XML));
      ArrayList&lt;Cliente&gt; list = clientes2.getClienteList();
      for (Cliente cliente : list) {
        System.out.println("Cliente: " + cliente.getNumeroPersona());
      }
    }
  } 
  </code></pre>