7 Replies Latest reply on Jan 31, 2011 1:50 PM by jaikiran

    Plugin required for ejb3 interceptors?

    kaiweing

      Hello,

       

      I am trying to use ejb3 Interceptors with JBoss AS 5.1.0.GA.

       

      Currently I am not sure when the ejb3 plugin is required, as JBoss AS 5.1 already offers many ejb3 features (annotations, JPA, ...).

       

      Do I need to install the ejb3 plugin (1.0.19) when I want to use ejb3 interceptors?

       

      Another question is, does this void the support in JBoss EAP?

       

      Thanks in advance for your help,

      Kai

        • 1. Plugin required for ejb3 interceptors?
          wolfc

          Interceptors are supported in AS 5.1. The plugin contains additional bug fixes.

           

          For EAP questions please contact support.

          • 2. Plugin required for ejb3 interceptors?
            kaiweing

            Hello Carlo,

             

            thanks for your quick response.

             

            Have you used ejb3 Interceptors in JBoss AS 5.1? I stick to the tutorial, but my EJB-Method is not being intercepted.

             

            This is my (test) code:

             

            Interceptor

             

            public class CallMonitoringInterceptor {

               

                private static final Logger logger = LoggerFactory.getLogger(CallMonitoringInterceptor.class);

               

                @javax.interceptor.AroundInvoke

                public Object monitorCall(InvocationContext ctx) throws Exception {

                    logger.info("monitoring {}...", ctx.getMethod().toGenericString());

                    return ctx.proceed();

                }

             

            }

             

            Intercepted business method

             

                @Override

                @javax.interceptor.Interceptors({CallMonitoringInterceptor.class})

                public Object service(String param1) throws Exception {

                    ...

                }

             

            Am I missing anything?

             

            Thanks in advance,

            Kai

            • 3. Plugin required for ejb3 interceptors?
              jaikiran

              Please post the exact source code including the annotations on the bean class.

              • 4. Plugin required for ejb3 interceptors?
                kaiweing

                The Interceptor code is complete as posted.

                 

                The EJB:

                 

                @javax.ejb.Stateless(name = "ejb/MyService")

                public class MyServiceImpl implements MyService {

                   

                    @Override

                    @javax.ejb.TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)

                    @javax.interceptor.Interceptors({CallMonitoringInterceptor.class})

                    public Object service(String param1) throws Exception {

                // ...

                    }

                }

                 

                and

                 

                @javax.ejb.Local

                public interface MyService {

                    Object service(String param1) throws Exception;

                }

                • 5. Plugin required for ejb3 interceptors?
                  jaikiran

                  That should have worked, assuming that you have correctly looked up the EJB via JNDI and invoked on it. What does your client code look like?

                  • 6. Plugin required for ejb3 interceptors?
                    kaiweing

                    I cannot really say why, but now it acutally works.

                     

                    Perhaps your karma helped :-)

                     

                    Anyway, thanks for your support.

                     

                    Kai

                    • 7. Plugin required for ejb3 interceptors?
                      jaikiran

                      Kai Weingärtner wrote:

                       

                      I cannot really say why, but now it acutally works.

                       

                      Good to know!