Hello,
I'm new to log4j, and just working my way through the examples in
Chapter 3 of the complete user manual. I may have discovered an
incompatibility between log4j and gnujaxp.
The setup:
I'm using Eclipse Galileo (Eclipse Java EE IDE for Web Developers),
for Mac OS X as my development environment. I am running Mac OS X
10.5.8. I have a project using Java 6.0 as the compiler and runtime
environment.
Additional jars that I have referenced in the project are:
junit-4.7.jar for unit testing
jdom.jar for working with Documents
jog4j-1.2.15.jar
xerces.jar (version 1.4.4)
LANLPlot.jar A library we've created using the JFreeChart
library (http://www.lanl.gov/orgs/da/d3/plot_library.shtml)
and then jars used as part of JFreeChart (http://www.jfree.org/):
gnujaxp.jar
jcommon-1.0.16.jar
jfreechart-1.0.13.jar
The problem:
When I first tried to run the example MyApp3 using the sample0.xml
configuration file, I had the following errors showing in the console:
log4j:WARN Parsing warning 2 and column 38
log4j:WARN URI was not reported to parser for entity [dtd]
log4j:WARN Parsing warning 2 and column 38
log4j:WARN missing system ID, using log4j.dtd
log4j:ERROR Could not parse file [sample0.xml].
gnu.xml.dom.DomEx: The operation violates XML Namespaces.
More Information: xmlns is reserved
Node Name: #document
at gnu.xml.dom.DomDocument.createAttributeNS(DomDocument.java:589)
at gnu.xml.dom.DomDocument.createAttribute(DomDocument.java:561)
at gnu.xml.dom.DomDocument.defaultAttributes(DomDocument.java:456)
at gnu.xml.dom.DomDocument.createElementNS(DomDocument.java:440)
at gnu.xml.pipeline.DomConsumer$Handler.startElement(DomConsumer.java:
602)
at gnu.xml.dom.Consumer$Backdoor.startElement(Consumer.java:203)
at gnu.xml.pipeline.EventFilter.startElement(EventFilter.java:570)
at
gnu
.xml.pipeline.ValidationConsumer.startElement(ValidationConsumer.java:
1177)
at gnu.xml.aelfred2.SAXDriver.startElement(SAXDriver.java:836)
at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1037)
at gnu.xml.aelfred2.XmlParser.parseDocument(XmlParser.java:416)
at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:167)
at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:
676)
at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:
789)
at
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:
682)
at
org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:811)
at gov.lanl.examples.log4j.chapter3.MyApp3.main(MyApp3.java:34)
log4j:WARN No appenders could be found for logger
(gov.lanl.examples.log4j.chapter3.MyApp3).
log4j:WARN Please initialize the log4j system properly.
When I get these error messages, the referenced jars on the build path
are showing in Eclipse in the following order:
junit-4.7.jar
jdom.jar
jog4j-1.2.15.jar
gnujaxp.jar
jcommon-1.0.16.jar
jfreechart-1.0.13.jar
LANLPlot.jar
xerces.jar
The Solution:
I removed the JFreeChart Libraries from the build path, and then added
them back in. Now the libraries are in the following order:
junit-4.7.jar
jdom.jar
jog4j-1.2.15.jar
xerces.jar
gnujaxp.jar
jcommon-1.0.16.jar
jfreechart-1.0.13.jar
LANLPlot.jar
Now when I run the same example I get the following in the console:
0 [main] INFO gov.lanl.examples.log4j.chapter3.MyApp3 - Entering
application.
2 [main] DEBUG gov.lanl.examples.log4j.chapter3.Foo - Did it again!
2 [main] INFO gov.lanl.examples.log4j.chapter3.MyApp3 - Exiting
application.
I don't know why the gnu library is substituting for the xerces
library, but I thought you might find this interesting.
John St. Ledger