5 Replies Latest reply on Nov 28, 2006 4:43 AM by mwoelke

    Interceptors and AroundInvoke

    mwoelke

      Hello there,
      I've a problem getting Interceptors to work in our EJB3-Application.
      I looked over the samples given in the EJB3Trail as well as in the tutorials available at jboss.com and implemented it accordingly, BUT it does not work, although the examples do work. I investigated this a little further and found that Interceptors only seem to work in certain context.
      I have a class A which is derived from an abstract class B. A implements an interface C which defines the business-methods for A. This interface is derived from interface D which defines business-methods implemented by B.

      public abstract class B{
      private static Logger logger = Logger.getLogger(B.class);
      @AroundInvoke
      public testAroundInvoke(InvocationContext ctx) throws Exception{
      logger.info("B.testAroundInvoke");
      return ctx.proceed();
      }
      }
      
      @Local public interface D{
      }
      
      @Local public interface C extends D{
      }
      
      @Stateless
      @Interceptor(TestInterceptor.class)
      public class A extends B implements C{
      ...
      }
      


      This way all business-methods of B, as defined by D, are intercepted by both, the external Interceptor and the internal of class B. Business-methods of A are not intercepted.
      If I remove the AroundInvoke method in B no interceptors at all are called anymore. Why is that? Am I doing something wrong or is this a bug?
      How do I get JBoss to intercept business-methods of A?

      Please help.

      Milan Wölke