java.lang.ClassCastException: javax.xml.bind.JAXBElement

When your XSD have no XMLRootElement that contains all types in one element, the code below is not applicable:
FooClass foo = (FooClass)unMarshaller.unmarshal(reader);

You should use the code below:
JAXBElement<FooClass> root = unmarshaller.unmarshal(inputStream,
FooClass.class);
FooClass foo = root.getValue();
XSD Comparison:
<xsd:element name="brs-reprint-param" type="brsReprintParam">
<xsd:key name="reportId">
<xsd:selector xpath="./report"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>

<xsd:complexType name="brsReprintParam">
<xsd:sequence>
<xsd:element name="report" type="reprintReport.CT"
minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="brs-reprint-param" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="report" type="reprintReport.CT"
minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:key name="reportId">
<xsd:selector xpath="./report"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>
XMLInputFactory factory = XMLInputFactory.newInstance();
 XMLStreamReader streamReader =         factory.createXMLStreamReader(reader);

留言

這個網誌中的熱門文章

Disable ionic's sidemenu content drag to toggle menu

Multiple writable mappings exist for the field. Only one may be defined as writable, all others must be specified read-only.

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser