0 Replies Latest reply on Oct 6, 2011 11:33 AM by Tom Tom

    Configuration issue for CDI interceptors

    Tom Tom Newbie



      Suppose I have a very simple webapp with no web content and only several classes :

      - "MyServiceInterface": a business service interface with only one method such as "String getMessage()"

      - "MyServiceBean": the corresponding implementation class, getMessage returns "Hello world!" and is annotated @Logged

      - "MyServlet": a servlet mapped to "/" that displays the message from the business service. Note that the business service is injected into this servlet using @Inject.

      - "Logged": a simple interceptor binding type

      - "LoggedImpl": the interceptor implementation class, displays a logging message in stdout such as "Executing method <method name here>"


      The packaging is:

      - No WEB-INF/classes at all

      - The five classes are packaged each in a dedicated jar in WEB-INF/lib (lib1.jar contains MyServlet, lib2.jar contains MyServiceInterface, lib3.jar contains MyServiceBean, lib4.jar contains Logged, lib5.jar contains LoggedImpl).

      - The CDI configuration is: an empty beans.xml in lib3.jar and a beans.xml describing the interceptor in lib5.jar


      => This works fine with JBoss 6.0.0 and 6.1.0 and also Resin 4.0.22, but both JBoss 7.0.1 and 7.0.2 fail: injection works fine but the interceptor is not executed.


      I'm upploading the test webapp "mockup7.war", the classnames may differ from the description above, but you get the picture. To test the issue: deploy, go to http://localhost:8080/mockup7/, then check the server stdout for the @Logged logging message.


      The question is: what is the correct CDI configuration here?


      Best regards