users@jersey.java.net

Re: [Jersey] Problem: Jersey swallows all JAXP exceptions silently !

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 24 Jul 2009 12:22:54 +0200

On Jul 24, 2009, at 12:06 PM, Morten wrote:

> --- Den fre 24/7/09 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
>> Did a 500 error get returned to the client? Did an
>> exception logged on the server side? If so can you send the
>> stack trace to me (i would like to know if we can improve
>> the logging in this area).
>
> Amazingly, I get a 200 OK response but with otherwise blank result.
> I got NO stack trace and no visible exceptions.
>

What HTTP container are you using?

If there is an error marshalling the JAXB object then Jersey will
throw an IOException to the underlying HTTP container, as the code in
the previous email presented (also, any other RuntimeException, expect
for WebApplicationException in certain cases, will go directly to the
underlying HTTP container).

My current guess is that the underlying HTTP container seems to be
ignoring the IOException (which wraps a JAXBException) thrown to the
underlying HTTP container.


> The reason I know that an exception is throw is because of the blank
> result + I DO get an exception show only IF I insert the following
> extra lines in my jersey controller method:
>
> JAXBContext c Marshaller m = context1.createMarshaller();
> m.marshal(x, System.err);ontext1 =
> JAXBContext.newInstance( SomeObject.class );
>
> Exception trace extract:
> com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 4
> counts of IllegalAnnotationExceptions
> JAXB annotation is placed on a method that is not a JAXB property
> this problem is related to the following location:
> at @javax.xml.bind.annotation.XmlElement(nillable=false,
> name=##default, required=false, defaultValue=
>

Is a JAXBException or a sub-class of thrown?

Paul.