DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3888>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3888

WebappClassLoader: Lifecycle error : CL stopped





------- Additional Comments From [EMAIL PROTECTED]  2002-10-18 14:36 -------
Hi.

I experienced the same problem and have been trying to find out something about
it. What I did is I modified the
org.apache.catalina.loader.WebappClassLoader.java and provoke an Exception in
it. Actually there are two places where this 'error' can occur, but in my case
it happens while trying to load a class.

So my debug part starts in line 1304 (tomcat 4.1.12) and looks like:
public Class loadClass(String name, boolean resolve)
    throws ClassNotFoundException {

    if (debug >= 2)
        log("loadClass(" + name + ", " + resolve + ")");
    Class clazz = null;

    String test = null;

    // Don't load classes if class loader is stopped
    if (!started) {
        log("###CLASS[" + name + "]### Lifecycle error : CL stopped");
        try {
          test.length();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
    ...

When the error occurs (strangely not on the first touch of a jar package,
instead only every after the first) it produces (in my case) the following output:

WebappClassLoader: ###CLASS[org.apache.log4j.helpers.NullEnumeration]###
Lifecycle error : CL stopped
java.lang.NullPointerException
        at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1317)
        at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1274)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
        at org.apache.log4j.Category.getAllAppenders(Category.java:394)
        at
org.apache.velocity.runtime.log.SimpleLog4JLogSystem.shutdown(SimpleLog4JLogSystem.java:200)
        at
org.apache.velocity.runtime.log.SimpleLog4JLogSystem.finalize(SimpleLog4JLogSystem.java:194)
        at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
        at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
        at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)

So it looks like that the Finalizer calls (in my case) velocity's
SimpleLog4JLogSystem's finalize method which it self calls Log4J's Category's
getAllAppenders method calls. This uses the static method from NullEnumeration
to return an instance variable. The problem is that this instance
is created by new NullEnumeration() so I guess that then this class has to be
found with the help of catalina's WebappClassLoader.

Please find here an extract:

public class NullEnumeration implements Enumeration {
  private static final NullEnumeration instance = new NullEnumeration();
...
  public static NullEnumeration getInstance() {
    return instance;
  }
...

Perhaps this NullEnumeration should be instantiated once in Log4J's init
procedure in order to have an instance already loaded in memory and the class
already resolved or velocity should not try to close all appenders in its
finalize. In my case I have a start-up servlet in my webapp which now contains
the following line in it's init method:

logger.debug("Log4J instance now in memory: " +
org.apache.log4j.helpers.NullEnumeration.getInstance());

And this works fine for me... So I am not an expert, but I hope that helps
everybody to sort out their problems because after all I don't think that this
is a proper bug. Due to the fact that is my first active part, comments and
critics of this posts are very welcome.

Best regards
Carsten Woelk

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>

Reply via email to