3 Replies Latest reply on Nov 20, 2009 6:12 AM by oyesiji77

    Logger is Null

    oyesiji77

      I have this Logger code segment in my page. Sometimes I get a Null Pointer Exception. Is there a way i can ensure that the Logger is always created

      @Logger private Log log;

        • 1. Re: Logger is Null
          niox.nikospara.yahoo.com

          Hi,


          Are you sure it is the log that is null and not some other object in the same line?


          Are you sure the component is always executed through Seam, so that DI takes place? (e.g. I can locate a session-scoped component and call its methods through a plain JSP... but then its dependencies would not be injected, probably resulting in NullPointerExceptions)


          Is there a deterministic sequence that reproduces the error?

          • 2. Re: Logger is Null
            kblief.kblief.gmail.com

            Yes, don't inject it.  Create it yourself.




            private static final Log log = Logging.getLog(Object.class);



            • 3. Re: Logger is Null
              oyesiji77

              Kurt Bliefernich wrote on Nov 19, 2009 21:46:


              Yes, don't inject it.  Create it yourself.



              private static final Log log = Logging.getLog(Object.class);






              Thanks it worked