users@jersey.java.net

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

From: Jeff Crump <jeffrey.crump_at_gmail.com>
Date: Mon, 10 May 2010 12:08:06 -0400

Thanks, I'll try that.

I know JAXB is recognizing the parser error because I've tracked it in the
debugger. The JAXB UnmarshallingContext.handleEvent method is being called
with "canRecover=true", so it never re-throws the exception, and the
property is never set. The other properly-formed properties are set as
expected.

Jeff

On 10 May 2010 11:41, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:

> 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
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>