try
{
JAXBContext jaxb = findJAXBContext(type, annotations, mediaType, true);
Unmarshaller unmarshaller = jaxb.createUnmarshaller();
unmarshaller = decorateUnmarshaller(type, annotations, mediaType, unmarshaller);
return (T) unmarshaller.unmarshal(new StreamSource(entityStream));
}
catch (JAXBException e)
{
Response response = Response.serverError().build();
throw new WebApplicationException(e, response);