4 Replies Latest reply on Oct 2, 2015 4:53 AM by huksley

    Interceptor in filter and servlet not working in weld-2.2.16.SP1 and apache-tomcat-8.0.26

    huksley

      Hello!

       

      I am trying to use interceptors and not Filter.doFilter nor HttpServlet.doGet is intercepted.

      The interception is fairly simple, just as in examples everythere (@Logged).

       

      @Inherited
      @InterceptorBinding
      @Retention(RetentionPolicy.RUNTIME)
      @Target({ ElementType.METHOD, ElementType.TYPE })
      public @interface Logged {
      }
      
      @Logged
      @Interceptor
      public class LoggedInterceptor implements Serializable {
        @AroundInvoke
        public Object logMethodEntry(InvocationContext invocationContext) throws Exception {
          System.out.println("Entering LoggedInterceptor"); // FIXME: NEVER GOES HERE!!!
          return invocationContext.proceed();
        }
      
      }
      
      
      @WebFilter
      
      public class TestFilterInject implements Filter {
        @Override
        @Logged
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          System.out.println("Entering filter");
          chain.doFilter(request, response);
        }
      }
      


       

      I have interceptor declared in /WEB-INF/beans.xml.

      I see lines "Entering filter" in stdout, but no lines "Entering LoggedInterceptor"...


      I`ve created ready to use web application huksley/TestWeldInterceptors · GitHub

      with more in it (quoted above is just an illustration).