Curt,
Thank you. I passed the filename as the argument--"sample0.xml". I'll
start using URIs.
The problem is caused by the system property. Both the gnujaxp and
xerces jar files declare services for
javax.xml.parsers.DocumentBuilderFactory, and
javax.xml.parsers.SAXParserFactory. I guess which ever service is read
first is the one used by the application. I need to learn more about
services and system properties.
Thanx again,
John
On Jan 6, 2010, at 7:52 PM, Curt Arnold wrote:
You did not specify what argument you passed to the command line for
"MyApp3". Neither the book or the docs make a big deal that the
argument to XMLConfigurator.configure(String) is expected to be a
URI and not a file spec. If you passed a relative URI, I could see
a parser complaining about not being able to resolve the relative
URI for the DTD even though log4j is going to ignore that URI and
load its own copy. There is a possibility that if you passed "file:///Users/yourusername/sample3.xml
, you might avoid at least some of the complaints. Removing the
DOCTYPE declaration may also remove a few spurious issues.
I haven't tracked gnujaxp for a very long time (in a previous
lifetime I spent a lot of time in XML standards work), but I'm
pretty confident that the problem is somewhere other than log4j. If
it is a standards conformance issue within gnujaxp, there is not
much that log4j can do to work around the issue.
http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance()
describes how JAXP finds the default implementation. You can
specify a system property to choose a particular implementation.
However if gnujaxp is being chosen preferentially to the JRE's
parser, some other code may explicitly configuring for use of gnujaxp.
On Jan 6, 2010, at 12:00 PM, John St. Ledger wrote:
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
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org