On Nov 19, 2008, at 4:05 PM, Eduardo Pérez Ureta wrote:
> I started using WebApplicationException and the Response object
> following your advice:
>
> @GET
> @ProduceMime("application/json")
> public JSONObject getMyObject(
>
> throw new javax.ws.rs.WebApplicationException(
> javax.ws.rs.core.Response.status(403).entity("Missing
> permissions at ...").type("text/plain").build()
> );
> );
>
> But I found that this exception that I just want to propagate to the
> user still gets propagated to the web container and logged.
What version of Jersey are you using?
WebApplicationException should never be propagated to the container
and the response set in WebApplicationException should be returned as
an HTTP response.
I would be surprised that you are observing that behavior because a
bunch of tests would break if that was the case.
Can you send the logged output?
Paul.
>
> This is not an exception that got unhandled but an exception I just
> want propagated to the WebService user.
>
> I am doing something wrong or should Jersey not propagate
> WebApplicationException to the Web Container?
>
> Or maybe I should always return Response (instead of JSONObject) if my
> web service may not return data because of an error or missing
> authorization?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>