users@jersey.java.net

HTTP 200 received when server throwing a WebApplicationException(500)

From: James Weir <James.Weir_at_Sun.COM>
Date: Thu, 14 Feb 2008 15:03:52 +0100

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