users@jersey.java.net

Re: [Jersey] Handling XML validation errors in the unmarshaller

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 10 May 2010 17:41:44 +0200

Hi Jeff,

There is a slightly simpler way.

Instead of using an implementation of ContextResolver<JAXBContext> you
can use an implementation of ContextResolver<Unmarshaller>, thus there
is no need to extend from JAXBContext.


When you say:

> The unmarshaller is correctly recognizing the parse error but
> chooses to skip the property rather than throw the error back up to
> my code.


How do you know JAXB is recognizing the parse error, because the
property is not set? If so that sounds odd. I would expect JAXB
unmarshalling to throw an exception in such cases.

Paul.

On May 10, 2010, at 5:08 PM, Jeff Crump wrote:

> Hello,
>
> I'm trying to figure out how to handle in a general way validation
> events that come from the unmarshaller on input. For example, my
> bean class has a Long-valued property but the client sends a value
> that cannot be converted to a Long. The unmarshaller is correctly
> recognizing the parse error but chooses to skip the property rather
> than throw the error back up to my code.
>
> I found this discussion in the archives regarding validation, and it
> sounds like a similar approach would work for me:
>
> https://jersey.dev.java.net/servlets/BrowseList?list=users&by=thread&from=1196351
>
> But since it's a couple of years old I was wondering if there was an
> easier way to accomplish this.
>
> Thanks,
>
> Jeff