users@jersey.java.net

[Jersey] Problem filtering web exceptions

From: Olivier Bourdon <olivier.bourdon_at_usharesoft.com>
Date: Wed, 22 Aug 2012 17:29:19 +0200

Hello everyone

Here is a piece of code which used to work and which does not anymore.
Note that I am currently
using jersey-1.10 (soon migrating to 1.13 I hope)

======================
File: src/xxx/.../UsersCreateResource.java:createUser
Response r = Response.status(Response.Status.CONFLICT).entity("User name
already taken, please choose another").build();
throw new WebApplicationException(r);
======================

which is supposed to return 409

my web service is also using specific exception filters
in glassfish web.xml I have

         <init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.me.rest.filters.ClientFilter;com.me.rest.filters.ErrorFilter</param-value>
         </init-param>

or in a standalone grizzly instance I set:
initParams.put(PackagesResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
"com.me.rest.filters.ClientFilter;com.me.rest.filters.ErrorFilter");

However when I enter my code which looks like:

public class ClientFilter implements ContainerResponseFilter {

     private static Logger logger = Logger.getLogger(ClientFilter.class);

     @Override
     public ContainerResponse filter(ContainerRequest cRequest,
ContainerResponse cResponse) {


the cResponse I have is now 400 instead of 409

May be I am misleading but I am pretty sure that this used to work
before with the same version of Jersey
therefore I was wondering what could have changed and if someone could
give me
some hints on how to debug this (webservice or standalone instance no
matter)

What might have changed is my Java version (was using 1.6.0_32 and now
1.7.0_04 therefore I redownloaded the previous Java version
and recompiled everything with it without any more success

Thanks a lot for any insights
Olivier