users@jersey.java.net

Re: HTTP 200 received when server throwing a WebApplicationException(500)

From: James Weir <James.Weir_at_Sun.COM>
Date: Fri, 15 Feb 2008 09:34:56 +0100

OK thanks, I think I will create a simple test case and log a bug
though, this was working for Jersey 0.4ea

Cheers
James

Martin Grotzke wrote:
> Hi James,
>
> I also experienced this yesterday, but with throw new WAE( Throwable,
> int ). As I had to include error information I changed the code to
>
> throw new WebApplicationException( Response.serverError()
> .type( "application/xml" ).entity( createAPIError( e ) ).build() );
>
> which then produced the correct return code - so I didn't investigate...
> So you might try s.th. like this as a first workaround.
>
> Cheers,
> Martin
>
>
> On Thu, 2008-02-14 at 15:03 +0100, James Weir wrote:
>
>> Hi,
>>
>> I have recently ported to Jersey 0.5. All went well, however in the
>> circumstances where I am throwing a WebApplicationException (error code
>> 500), I receive a 200 code on the client side.
>>
>> My code on the server side:
>>
>> try {
>> ...some code
>> } catch (Exception ex) {
>> logger.error("Creating the package",ex);
>> throw new WebApplicationException(500);
>> }
>>
>> I receive the following trace on the client side:
>> 14:57:18,343 DEBUG [Thread-4] (MyPackageMsg.java:MyPackageMsg:121) -
>> Return code from request: 200
>>
>> I am using the Jersey client to do the request:
>> The code:
>>
>> ResponseInBound ri = r.content(pkg,
>> "application/xml").accept("application/xml").post(ResponseInBound.class);
>>
>> // Set the response and return codes
>> super.setHttpResponseCode(ri.getStatus());
>> logger.debug("Return code from request: "+ri.getStatus());
>>
>> Has anyone else seen this behavior ?
>> I will create a simple example to try and reproduce this problem
>> Thanks
>> James
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>