I am trying to set up a request filter because I'd like to check some http header information before calling my logic. Unfortunately my filter never gets called in JBoss AS7.1.1. I already tried to update the RestEasy implementation (module) to 3.0.6 like described in the RestEasy documentation. It says you just have to replace the directories delivered by the new implementation zip-file and I did so. The AS started without any errors but the behavior does not change in any way. Each request stays unintercepted. I extracted this code from a more complex example but even this simple thing does not work:
Filter.java
import java.io.IOException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;
@Provider
@Secured
public class SecurityFilter implements ContainerRequestFilter {
public void filter(ContainerRequestContext crc) throws IOException {
throw new IllegalStateException("Not in my house");
}
}
ItemsResource.java
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
@Path("/Items")
public class ItemsResource {
@GET
@Produces("application/json")
@Secured
public String getJson() {
return "{\"id:\" \"1\"}";
}
}
ApplicationConfig.java
@javax.ws.rs.ApplicationPath("rest")
public class ApplicationConfig extends Application {
}
Secured.java
import javax.ws.rs.NameBinding;
@NameBinding
public @interface Secured {}
I does not change anything if I try to use the interceptor and the resource without the annotation. I would expect all the requests have to be intercepted but non will. I don't have any glue what to do. May anybody help we with some piece of advice? Let be add some addition thing. I tried the same thing with Wildfly (JBoss 8.0.0 Final). Interception by using @NameBinding and applying a custom annotation does not work also but if I don't use the annotation and just annotate the interceptor with @Provider all of my request get intercepted. Do I have to migrate to Wildfly or what?