title: What can cause @XmlRootElement classes to be unmarshalled into JaxbElement?
body: <p>I am currently trying to unmarshal an XML document via JAXB.  I've already have generated the JAXB classes within my project, and have a root class annotated with @XmlRootElement.</p>
  
  <p>Unfortunately, when I attempt to unmarshal, I receive the following exception:</p>
  
  <pre><code>java.lang.ClassCastException: javax.xml.bind.JAXBElement cannot be cast to a.b.Foo
  </code></pre>
  
  <p>My Foo class has the proper annotation, and as far as I'm aware, this should be able to unmarshal my XML into the Foo class.</p>
  
  <p>Any thoughts on what could cause this?</p>
  
  <p>Edit (for clarification):
  The call I'm attempting to make to unmarshal is this:</p>
  
  <pre><code>Foo foo = (Foo)unmarshaller.unmarshal(input);
  </code></pre>
  
  <p><strong>Second Update</strong>
  I'm not allowed to update our schema, but below is the XML schema structure to the 'Foo' element...</p>
  
  <pre><code>&lt;xsd:element name="Foo" type="Foo_Type"/&gt;
  &lt;xsd:complexType name="Foo_Type"&gt;
      &lt;!-- more schema definition here --&gt;
  &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>I am then adding the @XmlRootElement annotatino to the Foo class via JAXB Bindings.  I've found that if I change the schema to be like so:</p>
  
  <pre><code>&lt;xsd:element name="Foo"&gt;
      &lt;xsd:complexType&gt;
          &lt;!-- more schema definition here --&gt;
      &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  </code></pre>
  
  <p>Everything works fine, but once again -- we're not supposed to be updating the schema.</p>