users@jersey.java.net

setting JAXB marshall/unmarshall error response message

From: Bao,Sam <Sam.Bao_at_Cerner.com>
Date: Tue, 4 Aug 2009 18:52:27 -0500

So I've got my own provider for validating of application/xml requests and it's doing validation fine when everything validates. My question is how do I set the response message body if the validation should fail. Currently it just returns a message saying the server returned a 400 error, but I would like to also spit back the actual validation error so I can know not just the fact the request is wrong, but what's wrong with the request. The WebApplicationException on line 99 of AbstractRootElementProvider class has this info, but it gets lost eventually in WebApplicationImpl line 1066 where the response exception is just not used. This is the stack at which happens:

 

WebApplicationImpl.onException(Throwable, Response, HttpResponseContext) line: 1051

WebApplicationImpl.mapWebApplicationException(WebApplicationException, HttpResponseContext) line: 1020

WebApplicationImpl.mapMappableContainerException(MappableContainerException, HttpResponseContext) line: 1004

WebApplicationImpl._handleRequest(WebApplicationContext, ContainerRequest, ContainerResponse) line: 715

WebApplicationImpl.handleRequest(ContainerRequest, ContainerResponse) line: 667

WebApplicationImpl.handleRequest(ContainerRequest, ContainerResponseWriter) line: 658

HttpHandlerContainer.handle(HttpExchange) line: 180

 

So how can I get the validation error to return in the response body? Creating a provider that extends AbstractRootElementProvider wouldn't matter because that's actually throwing the exception, right? So not sure what to do here.

 

Also, I noticed theres AbstractListElementProvider and AbstractJAXBElementProvider, and I'm not sure when they're used. There's no class level javadoc, and through all the requests I've sent using unit tests, I have yet to step through those classes.

 

Any hints and tips would be greatly appreciated. Thanks.

----------------------------------------------------------------------
CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.