1 Reply Latest reply on Nov 27, 2008 11:26 AM by d_p_ludwig

    JBoss AS 4.2.3: Lifecycle event callbacks not invoked?

    d_p_ludwig

      Maybe a bug. I'm obersving some strange behaviour regarding the EJB 3 lifecycle event callbacks in JBoss AS 4.2.3.

      I got a simple stateful session bean which declares some lifecycle callback methods as shown below (simplified):

      @Stateful
      public class StatefulSessionLifecycleLoggerImpl implements MyBusinessInterface {
       [...]
      
       /**
       * {@inheritDoc}
       */
       public void businessMethod() {
       }
      
       @PostConstruct
       private void logPostConstruct() {
       log.info("[PostConstruct] [" + this.toString() + "]");
       }
      
      }
      


      When I lookup the bean everything works as expected, the logPostConstruct method gets called, everthing is fine. Now, when I declare a class-level interceptor for this bean

      [...]
      @Interceptors({MethodInvocationLogger.class})
      public class StatefulSessionLifecycleLoggerImpl [...]
      
      


      which also declares a callback method for the "PostConstruct" lifecycle event (code shown below, simplified)

      public class MethodInvocationLogger implements Serializable {
       [...]
      
       @PostConstruct
       public void init(InvocationContext ctx) {
       [...]
       }
      
       @AroundInvoke
       public Object logMethodInvocation(InvocationContext ctx) throws Exception {
       [...]
       }
      
      }
      


      then things start getting weird. The "PostConstruct" callback on the MethodInvocationLogger interceptor is being called, but the "PostConstruct" callback on the actual bean is _not_!!! As far as I understand the EJB specification both methods must have been called. Is this a bug or am I missing something?

        • 1. Re: JBoss AS 4.2.3: Lifecycle event callbacks not invoked?
          d_p_ludwig

          OK, my bad. I should have read further down the EJB specification (chapter 12.5):

          (...) Interceptor methods must always call InvocationContext.proceed() or no subsequent interceptor methods or bean business method or lifecycle callback methods will be invoked. (...)


          My interceptor did not call the proceed method. Works now.