I would like to check the JAX-RS web service request so that the correct XML is included in the body. However, this code:
@PUT
@Produces(MediaType.TEXT_XML)
@Consumes(MediaType.TEXT_XML)
@Path("/{objectID}")
public MyObject updateMyObject(@PathParam("objectID") String existingObjectID, JAXBElement<MyObject> object)
{
MyObject udpatedObject = null;
try
{
udpatedObject = object.getValue();
}
catch (Throwable ex)
{
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
}
returns an internal internal server 500 error instead of the expected 400 error. Is there a way to catch the exception?
Start of exception stack trace:
Local Exception Stack:
Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred unmarshalling the document
Internal Exception: org.xml.sax.SAXParseException: Premature end of file.
at org.eclipse.persistence.exceptions.XMLMarshalException.unmarshalException(XMLMarshalException.java:92)
source
share