2 Replies Latest reply on Sep 17, 2007 9:33 PM by Terry

    Seam Logger return NullPointerException

    Terry Apprentice

      When using seam logger in my class, it throws NullPointerException. But similar code works in Authenticator class that seam-gen creates.

      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.log.Log;
      ...

      @Name("activityLogger")
      public class ActivityLogger {

      @Logger
      Log seamLogger;

      ...


      public void log() {

      OrgUserActivityLogHome orgUserActivityLogHome = new OrgUserActivityLogHome();
      ...

      seamLogger.info("seam logger test #0", "ok"); <-- line throwing exception

      ...

      }
      }



        • 1. Re: Seam Logger return NullPointerException
          Pete Muir Master

          You can't instantiate Seam managed objects with new, you need to use injection or programmatic lookup using Component.getInstance()

          • 2. Re: Seam Logger return NullPointerException
            Terry Apprentice

            Hi and thank you, I understood my first problem that not to instantiate seam managed objects.

            however, I am still not clear about injection. Not sure what wrong I am doing there. Please see below, why does seamLogger.info(...) return NullPointerException?

            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.log.Log;
            ...

            @Name("activityLogger")
            public class ActivityLogger {

            @Logger
            Log seamLogger;

            ...

            public void log() {
            seamLogger.info("seam logger test #0", "ok"); <-- line throwing exception
            }
            }