3 Replies Latest reply on Oct 17, 2006 12:04 PM by gavin.king

    PostConstruct annotation

    monkeyden

      In the Javadoc this annotation shows:

      "The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization."

      However, when I try to run this code:

      @Logger
      private Log log;
      
      @PostConstruct
      public void someMethod(){
       log.debug("Some message");
       ....
      }


      ...it chokes on the logger with a NullPointer. The method meets all the requirements for @PostConstruct. Naturally, if I replace this line with a call to System.out, it works as expected.

        • 1. Re: PostConstruct annotation
          gavin.king

          In Seam 1.1, the @PostConstruct method is called after Seam "configures" the component, which includes injection of the Log) (In Seam 1.0.1, this is not the case.)

          But note that the "injection" talked about in the javadoc for @PostConstruct has *nothing* to do with Seam injection via @In. They are talking about EJB3 container injection using @Resource.

          • 2. Re: PostConstruct annotation
            monkeyden

            Dare I presume that the relationship is static, and @PostConstruct will always perform injection before any Seam annotations, or is it active and unreliable?

            • 3. Re: PostConstruct annotation
              gavin.king

              You should not presume *anything* for now, because the behavior will change utterly in Seam 1.1