users@jersey.java.net

[Jersey] Re: security filter does not get called if more than one filter is configured on the servlet adapter

From: Petr Jurák <petr.jurak_at_gmail.com>
Date: Fri, 3 Jun 2011 22:13:50 +0200

Hi,

IMHO it's due to replacement of the init parameter under name
ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS.
You should use list of filters instead. See [1].

BR, Petr

[1] http://jersey.java.net/nonav/apidocs/latest/jersey/index.html

2011/6/3 Arul Dhesiaseelan <aruld_at_acm.org>:
> Hi,
>
> I created an instance of Grizzly server as shown:
>
>     ServletHandler jerseyAdapter = new ServletHandler();
>
> jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages",
> "resources");
>     jerseyAdapter.setContextPath("/master");
>     jerseyAdapter.setServletInstance(new ServletContainer());
>
> jerseyAdapter.addInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
> SecurityFilter.class.getName());
>
> jerseyAdapter.addInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS,
> LoggingFilter.class.getName());
>
> jerseyAdapter.addInitParameter(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS,
> LoggingFilter.class.getName());
>     HttpServer webServer =
> GrizzlyServerFactory.createHttpServer(getBaseURI(), jerseyAdapter);
>
> If I configure the security filter as the first one as shown in the above
> code, it never gets called. If I move the security filter to the last spot,
> then it gets called. Is there a known problem with the ordering of filters?
>
> I am using Jersey 1.7.
>
> -Arul
>