title: ContainerRequestFilter is not executed in JAX-RS / RESTEasy application
body: <p>I am trying to create a filter for a REST API I have developed following these question <a href="https://stackoverflow.com/questions/26777083/best-practice-for-rest-token-based-authentication-with-jax-rs-and-jersey">Best practice for REST token-based authentication with JAX-RS and Jersey</a>.</p>
  
  <p>The problem is whatever of the methods I am invoking the filter doesnt appear to work.</p>
  
  <p>These are my classes:</p>
  
  <p><strong>Secured.java</strong></p>
  
  <pre><code>@NameBinding
  @Retention(RetentionPolicy.RUNTIME)
  @Target({ElementType.TYPE, ElementType.METHOD})
  public @interface Secured { 
  
  }
  </code></pre>
  
  <p><strong>AuthenticationFilter.java</strong></p>
  
  <pre><code>@Secured
  @Provider
  @Priority(Priorities.AUTHENTICATION)
  public class AuthenticationFilter implements ContainerRequestFilter{
  
      @Override
      public void filter(ContainerRequestContext requestContext) throws IOException {
          // Get the HTTP Authorization header from the request
          String authorizationHeader = 
              requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
  
          // Check if the HTTP Authorization header is present and formatted correctly 
          if (authorizationHeader == null || !authorizationHeader.startsWith("Bearer ")) {
              throw new NotAuthorizedException("Authorization header must be provided");
          }
  
          // Extract the token from the HTTP Authorization header
          String token = authorizationHeader.substring("Bearer".length()).trim();
  
          try {
  
              // Validate the token
              validateToken(token);
  
          } catch (Exception e) {
              requestContext.abortWith(
                  Response.status(Response.Status.UNAUTHORIZED).build());
          }
      }
  
      private void validateToken(String token) throws Exception {
          // Check if it was issued by the server and if it's not expired
          // Throw an Exception if the token is invalid
      }
  
  }
  </code></pre>
  
  <p><strong>RestService.java</strong></p>
  
  <pre><code>@Path("/test")
  public class RestService {
  
  TestDAO testDAO;
  
      @GET
      @Secured
      @Path("/myservice")
      @Produces("application/json")
      public List&lt;Test&gt; getEverisTests() {
          testDAO=(TestDAO) SpringApplicationContext.getBean("testDAO");
  
          long start = System.currentTimeMillis();
  
          List&lt;Test&gt; ret =  testDAO.getTests();
  
          long end = System.currentTimeMillis();
  
          System.out.println("TIEMPO TOTAL: " + (end -start));
  
          return ret;
  
      }
  }
  </code></pre>
  
  <p><strong>RestApplication.java</strong></p>
  
  <pre><code>public class RestApplication extends Application{
      private Set&lt;Object&gt; singletons = new HashSet&lt;Object&gt;();
  
      public RestApplication() {
          singletons.add(new RestService());
          singletons.add(new AuthenticationFilter());
      }
  
      @Override
      public Set&lt;Object&gt; getSingletons() {
          return singletons;
      }
  }
  </code></pre>
  
  <p>I am missing something? Thanks in advance.</p>