throws JAXBException {
CachedOutputStream out = new CachedOutputStream();
try {
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
StaxUtils.copy(new StaxSource(reader), writer);
writer.writeEndDocument();
writer.flush();
writer.close();
return unmarshalFromInputStream(unmarshaller, out.getInputStream(), anns, mt);
} catch (Exception ex) {
throw ExceptionUtils.toBadRequestException(ex, null);