I\'m trying to use a ContainerRequestFilter to enforce some authentication on a Tomcat based Jersey application. I followed this document.
Problem : the filter
Instead of using the @Provider annotation (which did not work in my case), you can register your ContainerRequestFilter manually with your JerseyServletFactory:
JerseyServletFactory jerseyServletFactory = new JerseyServletFactory(config);
HttpServlet myServiceServlet = jerseyServletFactory.create(myResource);
// Register your ContainerRequestFilter like this
jerseyServletFactory.addRequestFilter(new MyFilter());
httpServer.register(myServiceServlet, "/api");
httpServer.start();