title: Getting a list of JAXBElement where I want a list of predefined java objects
body: <p>I use Apache Camel + JAXB for Soap processing. The java glasses are generated by a maven plugin called cxf-codegen-plugin.</p>
  
  <p>The Problem I am facing is that when I want to use a property which is a list. In that case I will always get a list of JAXBElement instead of objects of the correct class.</p>
  
  <p>Assume this given xml snipped:</p>
  
  <pre><code>&lt;domainObjects avqxsi:type="avqsq:AssetAllocation" id="100" name="Some Name"&gt;
      &lt;nodes&gt;101&lt;/nodes&gt;
      &lt;nodes&gt;102&lt;/nodes&gt;
    &lt;/domainObjects&gt;
  </code></pre>
  
  <p>Now all the "nodes" are ids of different domain objects of type <code>AANode</code>. So in the xsd it is defined like so:</p>
  
  <pre><code>&lt;xsd:complexType name="AssetAllocation"&gt;
      &lt;xsd:complexContent&gt;
        &lt;xsd:extension base="avqsq:DomainObject"&gt;
          &lt;xsd:sequence&gt;
            &lt;xsd:element ecore:reference="avqsq:AANode" maxOccurs="unbounded" name="nodes" type="xsd:IDREF"/&gt;
          &lt;/xsd:sequence&gt;
        &lt;/xsd:extension&gt;
      &lt;/xsd:complexContent&gt;
    &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>And I have defined some bindings.xml:</p>
  
  <pre><code>&lt;jaxb:bindings node="xsd:complexType[@name='AssetAllocation']//xsd:element[@name='nodes']"&gt;
              &lt;jaxb:property&gt;
                  &lt;jaxb:baseType name="my.api.xsd.AANode"/&gt;
              &lt;/jaxb:property&gt;
          &lt;/jaxb:bindings&gt;
  </code></pre>
  
  <p>What I want is a POJO property like this:</p>
  
  <pre><code>@XmlElementRef(name = "nodes")
  protected List&lt;AANode&gt; nodes;
  </code></pre>
  
  <p>But what I actually get at <strong>runtime</strong> is a <code>List&lt;JAXBElement&lt;AANode&gt;&gt;</code> which leads into a ClassCastException.</p>
  
  <p><strong>EDIT 1:</strong>
  I have missed the fact that the cxf-codegen framework is generating a class where you clearly can see that the property is annotated with <code>JAXBElement.class</code> which i think is wrong. Interestingly changing the annotation by hand to AANode.class will fail with an <em>IllegalAnnotationException: AANode" or any of its subclasses are not known to this context.</em></p>
  
  <pre><code>public class AssetAllocation
      extends DomainObject
      implements Serializable, Equals, HashCode, ToString
  {
  
      @XmlElementRef(name = "nodes", type = JAXBElement.class)
      protected List&lt;AANode&gt; nodes;
  </code></pre>