You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by John Lindsey <ni...@pobox.com> on 2001/01/08 05:07:42 UTC

odd problem with log4j + tomcat + junit

Hi, I just started using log4j (it looks great so far!) and I'm having
an odd problem.

I'm doing some servlet stuff with Tomcat, and I can't get my servlets to
log via log4j.  When my servlet trys to load my log conf file via
DOMConfigurator.configure(), it generates this exception:



2001-01-07 10:43:40 - Ctx( /vppservlets ): Exception in: R( /vppservlets
+ /FindGroup + null) - java.lang.NoSuchMethodError
        at
org.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.ja
va:101)
        at
org.log4j.xml.DOMConfigurator.parseChildrenOfCategoryElement(DOMConfigur
ator.java:329)
        at
org.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:287)
        at org.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:591)
        at
org.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:444)
        at
org.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:533)
        at com.incanta.vppcr.FindGroup.<init>(FindGroup.java:34)
        at java.lang.Class.newInstance0(Native Method)
        at java.lang.Class.newInstance(Class.java:237)
        at
org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:26
8)
        at
org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
        at org.apache.tomcat.core.Handler.service(Handler.java:254)
        at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
a:797)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
ttpConnectionHandler.java:210)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
8)
        at java.lang.Thread.run(Thread.java:484)



Line 101 of org.log4j.xml.DOMConfigurator.findAppenderByReference is:

	Element element = doc.getElementById(appenderName);

Hmm, so it seems Tomcat can't find the getElementById(string) method.
But Tomcat is using the same class path as junit, and the log4j calls in
my junit tests (which are identical to the ones in my servlets) work
just fine: they throw no exceptions and produce the output that one
would expect.

Clearly, I must simply have something configured wrong.  I thought I
would try this list (after the FAQ and google failed to help) in the
hope that someone else had seen this sort of thing and could simply say
"oh, you need to do foo."

Thanks.

Oh, BTW, I'm using the latest release versions of everything: tomcat,
log4j, junit, xerces, etc.

--
John Lindsey    mailto:nisroc@pobox.com    http://pobox.com/~nisroc


Re: odd problem with log4j + tomcat + junit

Posted by Ceki Gulcu <ce...@apache.org>.
Hi John,

This is a known problem which is due to a screw up on my part. The 
DOMConfigurator.configure(URL) requires the presence of a JAXP compatible 
parser along with the Java DOM Level 2 bindings. The only parser that 
fulfills both requirements is Xerces. However, it turns out that DOM Level 
2 is not really required.

In log4j 1.0 scheduled for today or maybe tomorrow, you will be able to use 
the DOMConfigurator along with Sun's XML parser.  Regards, Ceki

At 23:07 07.01.2001 -0500, you wrote:
>Hi, I just started using log4j (it looks great so far!) and I'm having
>an odd problem.
>
>I'm doing some servlet stuff with Tomcat, and I can't get my servlets to
>log via log4j.  When my servlet trys to load my log conf file via
>DOMConfigurator.configure(), it generates this exception:
>
>
>
>2001-01-07 10:43:40 - Ctx( /vppservlets ): Exception in: R( /vppservlets
>+ /FindGroup + null) - java.lang.NoSuchMethodError
>         at
>org.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.ja
>va:101)
>         at
>org.log4j.xml.DOMConfigurator.parseChildrenOfCategoryElement(DOMConfigur
>ator.java:329)
>         at
>org.log4j.xml.DOMConfigurator.parseCategory(DOMConfigurator.java:287)
>         at org.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:591)
>         at
>org.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:444)
>         at
>org.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:533)
>         at com.incanta.vppcr.FindGroup.<init>(FindGroup.java:34)
>         at java.lang.Class.newInstance0(Native Method)
>         at java.lang.Class.newInstance(Class.java:237)
>         at
>org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:26
>8)
>         at
>org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
>         at org.apache.tomcat.core.Handler.service(Handler.java:254)
>         at
>org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
>         at
>org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
>a:797)
>         at
>org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>         at
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
>ttpConnectionHandler.java:210)
>         at
>org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
>)
>         at
>org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:49
>8)
>         at java.lang.Thread.run(Thread.java:484)
>
>
>
>Line 101 of org.log4j.xml.DOMConfigurator.findAppenderByReference is:
>
>         Element element = doc.getElementById(appenderName);
>
>Hmm, so it seems Tomcat can't find the getElementById(string) method.
>But Tomcat is using the same class path as junit, and the log4j calls in
>my junit tests (which are identical to the ones in my servlets) work
>just fine: they throw no exceptions and produce the output that one
>would expect.
>
>Clearly, I must simply have something configured wrong.  I thought I
>would try this list (after the FAQ and google failed to help) in the
>hope that someone else had seen this sort of thing and could simply say
>"oh, you need to do foo."
>
>Thanks.
>
>Oh, BTW, I'm using the latest release versions of everything: tomcat,
>log4j, junit, xerces, etc.
>
>--
>John Lindsey    mailto:nisroc@pobox.com    http://pobox.com/~nisroc
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org