1 Reply Latest reply on Jan 4, 2009 4:04 PM by Pete Muir

    use @PostConstruct in session bean

    Tobias Koltsch Newbie

      Hi,


      I have some problems to make use of @PostConstruct in my session bean.


      I followed the instructions in the Reference Guide and registered the SessionBeanInterceptor as default interceptor for all EJBs. Now I write my own session bean which contains a method annotated with @PostConstruct. The session bean works fine, but the @PostConstruct method is never invoked!


      I take a look at the source code from the SessionBeanInterceptor and see this is a lifecycle callback interceptor. When the @PostConstruct callback is intercepted, javax.interceptor.InvocationContext.proceed() is never invoked. So the annotated method in my session bean could never invoke too.


      In the spec at chapter 5.8 I find this:
      “When the EJB container creates a new instance of an EJB bean, the Web Bean manager intercepts the @PostConstruct callback and performs the following steps, before the callback is allowed to proceed to the bean instance.“


      May I'm wrong, but I think to proceed the callback is the desired behavior?




      Greetings

      Tobias