9 Replies Latest reply on Jun 8, 2012 2:53 AM by Dmitri Zamysloff

    Doubt with CDI Interceptors in AS 7

    Wilson Guimarães Newbie

      Hi,

       

      We've created two projects: cdijar and webapp (https://github.com/zyc/jboss-as7-lab/tree/master/interceptors/scenario1). On cdijar we've implemented an interceptor bindig (MyInterceptorBinding) and its respective interceptor (MyInterceptor.java) that simply prints a message on console. The beans.xml was defined inside META-INF in the same project. webapp depends on cdijar and defines a bean (MyBean.java) whose method (public void method()) is annotated with @MyInterceptorBinding and prints another message on console. In this case, beans.xml is empty. To put all this together, we've created an index.html with a button that executes method().

       

      What we expect to be shown on console is the following:

      This is an interception.

      At this point, an interception should have occurred.

       

      That's exactly what happens when running the example on Jboss AS 6. However, the same doesn't occur on AS 7. Instead, when pushing the button on index.xhtml the only message printed is the one defined on MyBean.java ("At this point, an interception should have occurred.").

       

      We've faced a similar problem with CDI Portable Extensions that was solved when beans.xml was defined inside WEB-INF in the webapp. With that in mind we did the same procedure, but didn't remove it from beans.xml inside cdijar. This way, everything works as expected on AS 7, but AS 6 raises an exception saying that the interceptor MyInterceptor was specified twice.

       

      Seems that, on AS 7, the beans.xml inside cdijar is being ignored. Is that the correct behaviour?

       

      Kind regards,

      Wilson Guimarães

      Cleverson Sacramento