[jboss-user] [EJB 3.0] - JBoss AS 4.2.3: Lifecycle event callbacks not invoked?

d_p_ludwig do-not-reply at jboss.com
Wed Nov 26 12:49:44 EST 2008


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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192583#4192583

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4192583



More information about the jboss-user mailing list