3 Replies Latest reply on Aug 17, 2005 9:14 AM by kabirkhan

    using aop on web app w/ log4j

    mlybarger

      i'm trying to use dynamic aop on a web application that uses log4j, and get this message on classes that are instrumented (non instrumented classes log just fine. The line of code that's in the is just:

      code:
      public static Logger LOG = Logger.getLogger(BaseAction.class);

      error:
      Caused by: java.lang.NullPointerException
      at org.apache.log4j.Logger.getLogger(Logger.java:94)
      at com.mlybarger.base.BaseAction.(BaseAction.java:50)
      ... 48 more

      any ideas why this would be happening? From what I can tell the Logger.getLogger method just calls LogManager.getLogger()

        • 1. Re: using aop on web app w/ log4j
          mlybarger

          after spending another minute on this, i changed the statement from:
          public static Logger LOG = Logger.getLogger(BaseAction.class);

          to:
          public static Logger LOG = Logger.getLogger(BaseAction.class.getName());

          This pushes the exception up from the log4j Logger class into my BaseAction class. for some reason, BaseAction.class, seems to be null when the class is being instrumented via jboss aop.

          • 2. Re: using aop on web app w/ log4j
            mlybarger

            i've changed the interceptor to have scope="PER_VM", and that seemed to resolve the issue.

            what would be really cool is if i could trap the classnotfound or npe exception via aop, and then identify the location of the .jar of the class being loaded which cannot find a dependant class.

            or maybe just add a static method to each class that displays the location of the jar it's loaded from each time it's loaded.

            • 3. Re: using aop on web app w/ log4j
              kabirkhan

              I've tried this in a standalone app, and had no problems. What does your packaging look like?