Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1391

ManagedBean interceptors' @PostConstruct methods not being invoked

XMLWordPrintable

      For the following classes (EJB, managed bean, and an interceptor)...

      // EJB
      @Stateless
      public class StatelessEJB {

      @Resource private SomeManagedBean mb;

      public String sayHello()

      { mb.foo(); return "Hello"; }

      }

      // Managed Bean
      @ManagedBean("somemanagedbean")
      @Interceptors(InterceptorA.class)
      public class SomeManagedBean {

      @PostConstruct
      private void init()

      { System.out.println("In SomeManagedBean::init() " + this); }

      public void foo()

      { System.out.println("In SomeManagedBean::foo() "); }

      @PreDestroy
      private void destroy()

      { System.out.println("In SomeManagedBean::destroy() "); }

      }

      // Interceptor
      public class InterceptorA {

      @AroundConstruct
      private void create(InvocationContext ctx) {
      System.out.println("In InterceptorA.AroundConstruct");
      try

      { ctx.proceed(); } catch (Exception e) { throw new RuntimeException(e); }
      }

      @PostConstruct // THIS METHOD IS NEVER INVOKED
      private void afterCreation(InvocationContext ctx) {
      System.out.println("In InterceptorA.PostConstruct");
      try { ctx.proceed(); }

      catch (Exception e)

      { throw new RuntimeException(e); }
      }

      @PreDestroy
      private void preDestroy(InvocationContext ctx) {
      System.out.println("In InterceptorA.PreDestroy");
      try { ctx.proceed(); } catch (Exception e) { throw new RuntimeException(e); }

      }

      @AroundInvoke
      public Object interceptCall(InvocationContext ctx) throws Exception

      { System.out.println("In InterceptorA.AroundInvoke"); return ctx.proceed(); }

      }

      I'm finding that the interceptor's @PostConstruct method is not being invoked. The @AroundConstruct method does appear to be invoked though.

              rhn-engineering-jharting Jozef Hartinger
              phil.zampino Phil Zampino (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: