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 16:05:24 +0200

On Jul 24, 2009, at 3:26 PM, Morten wrote:

> --- Den fre 24/7/09 skrev Paul Sandoz <Paul.Sandoz_at_Sun.COM>:
>>> I am using Sun's HTTPSERVER
>>>
>>
>> Hmm... the Jersey LW HTTP HttpHandlerContainer is written
>> such that an IOException will be thrown from the handle
>> method. I suspect that when the status code and headers are
>> set such exceptions do not result in premature termination
>> of the connection (plus no logging occurs).
>
> If I understand you correctly, then Jersey sets the status code
> prematurely (before it is sure that no exceptions are throw in JAXB) ?
>

No. Jersey has to set the response headers and status code before
writing out the response. The status and headers are set just before
the first byte is written to the output stream (the OutputStream is
wrapped).



>> If you don't have any specific configuration with that
>> container it is easy to switch to using Grizzly to verify if
>> you get the same behaviour.
>
> Actually, it is quite some work for me to switch as I am using
> HTTPServer internally as an very light-weight embedded web server.

One thing you could do is wrap Jersey's HttpHandler implementation
around your own handler to check if any runtime exceptions are passed
through.


> I am not using servles, war files or the std j2ee structure.
> However eventually, I may have to switch to another embedded web
> server anyway as I would like to support digest authentication. It
> will take some time though.
>
> Would it be helpful if I instead create a small hello-world-style
> example that reproduce the problem for you (I can properly do so in
> a day or so if needed) ?

Yes, that would be most useful.


> And if I do, what is the chance it can be fixed for jersey 1.1.2 (as
> it is highly annoying and actually a "crime" to swallow exceptions
> and return success :-))
>

The thing is i am not sure it is a bug in Jersey. Currently i think it
is a bug in the LW HTTP server. A test case would help be verify if
that is the case and if so perhaps there might be a work around.

Paul.