You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by __matthewHawthorne <ma...@phreaker.net> on 2003/09/08 17:41:32 UTC

Re: Debugging LogConfigurationException with commons-logging 1.0.3 (and log4j 1.2.8)

I've experienced a fair amount of problems with similar looking stack 
traces, all of which were related to commons-logging/log4j versioning 
issues.  However, from what I can tell, your versions look OK. 
Typically it happens with the older versions of log4j.

Perhaps commons-logging is having problems instantiating the underlying 
log4j class.  You say you are running "standalone" code, I interpret 
this to mean that you are not running inside of a container? (such as 
Tomcat, Weblogic, etc).  Sometimes the classloading inside of containers 
can be confusing.

I've never heard of this logging.properties file, I didn't think that 
commons-logging allowed any direct configuration.  Try to reference a 
log4j class directly, before your call to commons-logging to make sure 
that the classes are loaded and accessible.

Maybe try to set the log4j system property (look in the log4j 
documentation, but I think it's log4j.debug=TRUE) to see if any 
configuration errors are occurring on the log4j side.

We need some better documentation for errors like this, they seem to 
happen a lot, and provide a consistent source of confusion.  I'd write 
them myself if I understood the problem better.

I hope this has been more helpful than chaotic...




Karr, David wrote:

> I'm trying to run some standalone code that uses commons-logging and
> log4j, but I'm getting a LogConfigurationException.  I can't find any
> useful information on what is really going wrong.
> 
> The stack trace is as follows:
> ----------------
> org.apache.commons.logging.LogConfigurationException:
> java.lang.reflect.InvocationTargetException
> 	at
> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImp
> l.java:532)
> 	at
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImp
> l.java:272)
> 	at
> org.apache.commons.logging.LogFactory.getLog(LogFactory.java:414)
> logger[null]
> 	at
> com.wamu.tsg.eai.reporting.collect.MessageManager.<init>(MessageManager.
> java:33)
> 	at
> com.wamu.tsg.eai.reporting.collect.MessageManager.main(MessageManager.ja
> va:55)
> java.lang.NullPointerException
> 	at
> com.wamu.tsg.eai.reporting.collect.MessageManager.main(MessageManager.ja
> va:83)
> ----------------
> 
> I have a "log4j.properties" file, which I'm putting in the classpath
> when the application is run.  I don't have a "logging.properties" file
> (I believe that's the name that commons-logging looks for).  I'm using
> JDK 1.3.1_08.
> 
> What else can I do to get more information about what is going wrong?




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


Re[2]: Debugging LogConfigurationException with commons-logging 1.0.3 (and log4j 1.2.8)

Posted by Anton Tagunov <at...@mail.cnt.ru>.
Hello, David!

(Err, sorry, this is a response to the original message by
David, but since all I have now is Mattew's response, I'm
responding to it.)

Karr, David wrote:

DK> I'm trying to run some standalone code that uses commons-logging and
DK> log4j, but I'm getting a LogConfigurationException.  I can't find any
DK> useful information on what is really going wrong.

DK> What else can I do to get more information about what is going wrong?

Wow, you can do much: when you print the stack trace to console
unfold any rootCause exceptions that are contained inside yours!

The containers will do that for you (here is a case when running
in a container is easier :-), but when you're on your own

e.printStackTrace() is not enough.

I heartely advice you to get some new commons-lang.jar
(is there are 2.0 release available already? if not some
nightly build?)

There's the

   org.apache.commons.lang.exception.ExceptionUtils

class there. There are static

   ExceptionUtils.printRootStackTrace(Throwable t, PrintStream ps)
   ExceptionUtils.printRootStackTrace(Throwable t, PrintWriter pw)

methods there. In fact, if you were on JDK 1.4
Throwable.printStackTrace() probably would have unfolded what you
need for you. But still AFAICT ExceptionUtils.printRootStackTrace
are a bit more comprehensive: while JDK 1.4
Throwable.printStackTrace() deals only with Throwable.getCause()
provided exception, while ExceptionUtils.printRootStackTrace
dead with

        "getCause",
        "getNextException",
        "getTargetException",
        "getException",
        "getSourceException",
        "getRootCause",
        "getCausedByException",
        "getNested"

methods (probably via reflection, but who cares if an error has happened :-)

There's also one more difference between Throwable.printStackTrace and
ExceptionUtils.printRootStackTrace - the former first prints the
outmost exception and the innermost - last, while the latter - first
the innermost (hence the name - printRootStackTrace - the root,
innermost) and last - the outmost exception. If my memory serves me
right.

Hope that when all this happens at the end of long unfolding you
gonna arrive to the real exception that will tell what has happened
;-)

It's all about people writing code like

   } catch( FooException foo ) {
     throw new BarException("Damn, I failed to do that!", foo);
   }

and all you get if you do not unfold will be this ultra-informative

    Damn, I failed to do that!

message!

Anton


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