use of jakarta.xml.bind.UnmarshalException in project spring-framework by spring-projects.
the class Jaxb2XmlDecoder method unmarshal.
private Object unmarshal(List<XMLEvent> events, Class<?> outputClass) {
try {
Unmarshaller unmarshaller = initUnmarshaller(outputClass);
XMLEventReader eventReader = StaxUtils.createXMLEventReader(events);
if (outputClass.isAnnotationPresent(XmlRootElement.class)) {
return unmarshaller.unmarshal(eventReader);
} else {
JAXBElement<?> jaxbElement = unmarshaller.unmarshal(eventReader, outputClass);
return jaxbElement.getValue();
}
} catch (UnmarshalException ex) {
throw new DecodingException("Could not unmarshal XML to " + outputClass, ex);
} catch (JAXBException ex) {
throw new CodecException("Invalid JAXB configuration", ex);
}
}
Aggregations