3 Replies Latest reply on Jan 5, 2011 3:46 AM by isonisak

    Logger injection in JBoss 6 Final ?

    isonisak

      Seam Logger don't inject with Seam 2.2.1.CR2, JBoss 6 Final.


      Application is generated by seam-gen and works fine.


      When loggging is added comes always NPE no matter how logging is instantiated.


      import org.jboss.seam.annotations.Logger;


      @Logger public Log log;


      log.debug(”test seam logging”); -- NPE


      @Logger private Log log;


      log.debug(”test seam logging”); -- NPE


      @Logger Log log;


      log.debug(”test seam logging”); -- NPE


      In JBoss AS 6 commmon lib is log4.jar and server start advertises this lib. I copied this jar to ../default/lib.


      Result is the same. Maybe jar must be in applications libraries in this AS version ?


       

        • 1. Re: Logger injection in JBoss 6 Final ?
          isonisak

          Hai


          This problem is not Seam version or platfrom spesific.


          Probably the cause is that appropriate class where query is started is not injected by Seam. This is bad architecture for new Seam users and I suggest that seam-gen is changed so, that server methods are called from UI so, that @Logger works.


          Why is the class not Seam injected although there is annotation @Name ?


          This requires that methods are instantiated from UI with #{bean.method} notation that causes, that Seam catches the call and injects Logger etc.


          Am I right ?


          • 2. Re: Logger injection in JBoss 6 Final ?
            stefanotravelli

            Since Seam components are managed components you have to let Seam  instantiate them.
            Referencing the component in EL is the common way. In some cases you can use Component.getInstance().

            • 3. Re: Logger injection in JBoss 6 Final ?
              isonisak

              OK


              I suppose that in Seam documentantion this is not emphasized
              enough.


              Sadly seam-gen produces architecture where @Logger cannot be used everywhere,
              so some clarifying is needed.