On Aug 15, 2007, at 9:56 AM, Wilfong, Paul wrote:

Some progress and new problems...

I found that the XMLDecoder class is not in the jar file "log4j-1.3alpha-8.jar"!

I looked in the other jar files that come in the 1.3alpha-8 distribution, and found that XMLDecoder seems to be in "log4j- all-1.3alpha-8.jar".

When I use this instead, I no longer get the "Unable to find decoder" message.


log4j 1.3 had split up itself into 8 or so different jars. The -all- jar was an response to restore an all-in-one jar that could be used as a replacement for log4j.jar.



However, now I get the following:
java.net.MalformedURLException: unknown protocol: dummy

The XMLDecoder code has the following at line 132: inputSource.setSystemId("dummy://log4j.dtd");
along with some comments regarding something called Crimson.

I'm not sure what to do at this point. Should I try to remove the "dummy://" and rebuild the class? Or can I get a previous distribution that might not have this problem?


Crimson is the name of the Sun developed XML parser that was provided with the first JAXP release (before XML parsing was part of the JDK). It was donated to the ASF and is dormant. Later JDK's provide a rebuilt version of the Apache Xerces 2 project.

I reviewed the code in the SVN and it appears that the decoder has always had potential problems, it is just they weren't apparent with some parsers and the current parser does some additional checks on the URL for the DTD before sending it off to an entity resolver at which time we ignore what it did and provide a precanned version of the log4j.dtd. I'd suggest:



Index: src/main/java/org/apache/log4j/xml/XMLDecoder.java
===================================================================
--- src/main/java/org/apache/log4j/xml/XMLDecoder.java (revision 566217)
+++ src/main/java/org/apache/log4j/xml/XMLDecoder.java  (working copy)
@@ -68,7 +68,7 @@
      */
   private static final String BEGINPART =
     "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
-    + "<!DOCTYPE log4j:eventSet SYSTEM \"log4j.dtd\">"
+    + "<!DOCTYPE log4j:eventSet SYSTEM \"http://localhost/log4j.dtd\";>"
     + "<log4j:eventSet version=\"1.2\" "
     + "xmlns:log4j=\"http://jakarta.apache.org/log4j/\";>";
     /**
@@ -165,7 +165,6 @@
       InputSource inputSource =
         new InputSource(new StringReader(buf.toString()));
-      inputSource.setSystemId("dummy://log4j.dtd");
       document = docBuilder.parse(inputSource);
     } catch (Exception e) {
       e.printStackTrace();


The problem also exists in the receivers companion for log4j 1.2. I'll going to add some unit tests around it there and confirm that those changes work as expected. If they do then I commit them plus tests to the receivers companion and just the fix to the abandoned 1.3 branch. I haven't followed this thread closely, but you should consider migrating away from log4j 1.3 to log4j 1.2 plus appropriate companions.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to