Wow, very fast! (Y)
On Fri, 2008-02-15 at 12:36 +0100, Paul Sandoz wrote:
> Hi,
>
> I can reproduce this, and have fixed the issue in the latest build, and
> i am currently, in the metaphorical sense, banging my head on the desk
> at my stupidity! Sorry about that:
>
> When a WebApplication of a 500 status code is returned and there is no
> entity associated with it Jersey creates a new response with an entity
> that is the stack trace, but i neglected to copy the status code:
>
> - r = Response.ok(sw.toString(), "text/plain").build();
> + r = Response.status(r.getStatus()).entity(sw.toString()).
> + type("text/plain").build();
>
> Paul.
>
> James Weir wrote:
> > 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
> >>>
> >>>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
>