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

ManagedBean interceptors' @PostConstruct methods not being invoked

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.0.0.Beta7
    • Fix Version/s: 2.0.0.CR1
    • Labels:
      None
    • Environment:

      @PostConstruct method of @Resource-injected ManagedBeans' interceptors are not being invoked.

      Description

      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.

        Gliffy Diagrams

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                jharting Jozef Hartinger
                Reporter:
                phil.zampino Phil Zampino
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development