• Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1_dev
    • Component/s: cdi
    • Labels:
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:


      This issue is filed subsequent to the discussion in issue 13513 . It seems CDI
      interceptor bindings are not working for EJBs. I have simplified the test case
      from issue 13513 to remove OSGi from the picture and converted it to a simple
      web application with a Servlet calling a local EJB which has some interceptors
      as shown below;

      public class MyServlet extends HttpServlet {
      @EJB UserService svc;

      public void service(ServletRequest req, ServletResponse res)

      { svc.findById(0); // call the ejb }


      @Secure // interceptor binding
      public class UserServiceImpl implements UserService {

      public User findById(long userId) throws EJBException {
      LOG.log(Level.INFO, "Returning user

      {0}", u);

      @Target({ TYPE, METHOD })
      public @interface Secure

      public class SecurityInterceptor implements Serializable
      protected Object invoke(final InvocationContext ctx) throws Exception
      LOG.log(Level.INFO, "EJB Method called [Full]:\"{0}

      \" by Principal:

      new Object[]{getFullEJBClassName(interfaceMethod), p.toString()});
      LOG.log(Level.INFO, "EJB Method called [Methodonly]:{0} by

      ", new Object[]

      {interfaceMethod.getName(), p.toString()}


      return ctx.proceed();

      If unzip the attached, it creates
      interceptor-ejb-cdi-test directory. Try the following:
      cd interceptor-ejb-cdi-test
      ./ (this will compile, deploy and run the servlet)
      See the server.log, you shall not find any message from the interceptor.

      Now, open
      uncomment the following line:

      and run ./ again. This time in server.log, you shall see interceptor
      message. As per the javadocs[1]:
      "If the target class is a CDI bean, by annotating both the interceptor class and
      the target class with an interceptor binding. "

      and as per CDI javadoc [2]:

      "Interceptors may be bound to any managed bean that is not itself an
      interceptor or decorator or to any EJB session or message-driven bean. An
      interceptor that is annotated @Interceptor may be identified by its interceptor


      1. GLASSFISH-14831.diff
        0.7 kB
        Sivakumar Thyagarajan



          • Assignee:
            Sivakumar Thyagarajan
            Sanjeeb Sahoo
          • Votes:
            1 Vote for this issue
            3 Start watching this issue


            • Created: