I found an acceptable solution on my own. I can create the ExceptionReport as a jaxb object, populate, and provide in an exception response as follows:
ExceptionReport er = populateExceptionReport();
throw new WebApplicationException(Response.status(Response.Status.ACCEPTED).
entity(er).type("application/xml").build());
From: Tim Clotworthy [mailto:tclotworthy_at_integratedsecure.com]
Sent: Thursday, November 05, 2009 7:57 AM
To: users_at_jersey.dev.java.net
Subject: [Jersey] custom exception output
Hello, I have a requirement from my customer that errors be returned from resources in a response with the following format:
<?xml version="1.0" ?>
<ExceptionReport
version="1.1.0"
xmlns="
http://www.opengis.net/ogc"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="owsExceptionReport.xsd">
<Exception code="999" locator="INSERT STMT 01">
<ExceptionText>parse error: missing closing tag for element wkbGeom</ExceptionText>
</Exception>
</ExceptionReport>
My question is, can this structure be accomplished by throwing WebApplicationException from the resource class, or will it require using ExceptionMapping Providers (or do you need more information)?
At the source, both checked and unchecked exceptions can be thrown and ultimately propagated up to the root resource (if that has any bearing). Thanks for any response.