logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig Newlander" <cnewlan...@eqtc.com>
Subject RE: Log4j and servlets - Reflection Error
Date Thu, 23 Aug 2001 13:53:16 GMT
Putting the log4j.jar file in the lib directory of WEB-INF/ works fine
for servlets (but the not the classes w/ lo4j referencesthat the servlet
refelcts

After putting the .jar file in the classpath everything works fine.

I guess that makes sense.


-----Original Message-----
From: Thomas Tuft Muller [mailto:ttm@online.no]
Sent: Thursday, August 23, 2001 1:39 AM
To: LOG4J Users Mailing List
Subject: RE: Log4j and servlets - Reflection Error


There's a few unintentional discrepencies in the various VMs with respect to
reflection. I've e.g. seen the InvocationTargetTxception if I reflect with
an anonymous class as opposed to an explicitly defined inner class.

BTW, unless Foo is a Singleton, the static log field will be assigned for
each invocation of the constructor. A side-effect (unless Foo is final) is
that you reassign it when a sub-class of foo is created as well (that is if
the constructor assigning 'log' is called by this sub-class constructor).
This is probably NOT your intention.

I use a similar technique, but I let the category reference be an instance
variable. More memory consumption, but less side-effect prone.

--

Thomas


| -----Original Message-----
| From: Craig Newlander [mailto:cnewlander@eqtc.com]
| Sent: 22 August 2001 15:55
| To: LOG4J Users Mailing List
| Subject: Log4j and servlets - Reflection Error
|
|
| Strange error here.
| In my Servlet class (foo) I defined a static field member as
|
| private static Category log;
|
| and in its Constructor is
| log = Category.getRoot();
| I can now log until the cows come home.
|
| Now then, I have another class (foobar) which is instantiated via
| reflection
| by foo from foo's service() method
|
| foobar has a static field member as
| private static Category log;
| and in its Constructor is
| log = Category.getInstance(  this.getClass().getName() );
|
| and when foo tries to reflect foobar I recevied a
| java.lang.reflect.InvocationTargetException:
| java.lang.NoClassDefFoundError:
| org/apache/log4j/Category
| foobar never gets instantiated foo keeps chugging along and logs without a
| hitch?
|
| if I remove the log = from foobars construtor foobar can be reflected just
| fine.
|
| Any ideas?
|
|
|
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
| For additional commands, e-mail: log4j-user-help@jakarta.apache.org
|
|



*************************************************************************
Copyright ERA Technology Ltd. 2001. (www.era.co.uk). All rights reserved.
Confidential. No liability whatsoever is accepted for any loss or damage
suffered as a result of accessing this message or any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message