Jersey ContainerRequestFilter not triggered

Okay, I didn’t get that the jersey.config.server.provider.packages init param needs to reference not only service classes (API endpoints) but ALL the classes including filters. Now it works : <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.hck.debate.rest.controller;com.hck.debate.rest.security</param-value> </init-param> <init-param> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> <param-value>com.hck.debate.rest.security.AuthFilter</param-value> </init-param>

Example of using StreamingOutput as Response entity in Jersey

See if this helps: @GET @Produces(MediaType.TEXT_PLAIN) public Response streamExample() { StreamingOutput stream = new StreamingOutput() { @Override public void write(OutputStream os) throws IOException, WebApplicationException { Writer writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(“test”); writer.flush(); // <– This is very important. Do not forget. } }; return Response.ok(stream).build(); }

What exactly is the ResourceConfig class in Jersey 2?

Standard JAX-RS uses an Application as its configuration class. ResourceConfig extends Application. There are three main ways (in a servlet container) to configure Jersey (JAX-RS): With only web.xml With both web.xml and an Application/ResourceConfig class With only an Application/ResourceConfig class annotated with @ApplicationPath. With only web.xml It is possible to configure the application in a … Read more