Commons Digester
  1. Commons Digester
  2. DIGESTER-63

The Digester can't find a "digester-rules.dtd", although it is located in commons-digester.jar

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      Running the following piece of code:
      d = new Digester();
      try {
      d.setValidating(false);
      d.addRuleSet(new FromXmlRuleSet(getClass().getResource("/myrules.xml")));
      d.push(this);
      d.parse(getClass().getResourceAsStream("/schema.xml"));
      } catch (MalformedURLException mue) {
      logger.error(mue);
      } catch (IOException ioe) {
      logger.error(ioe);
      } catch (SAXException se) {
      logger.error(se, se);
      }
      I have got the exception:
      [java] org.apache.commons.digester.xmlrules.XmlLoadException:
      E:\projects\test\digester\digester-rules.dtd (The system cannot find the file
      specified)
      [java] at org.apache.commons.digester.Digester.addRuleSet(Digester.java:1663)
      [java] at com.sunbay.test.MyDigester.<init>(MyDigester.java:23)
      [java] at com.sunbay.test.Startup.test(Startup.java:46)
      ...

      It is obvious that the system is trying to find "digester-rules.dtd" DTD,
      but why it searches in my project root?
      While debugging the org/apache/commons/digester/xmlrules/FromXmlRuleSet.class,
      I have found the following line:
      URL dtdURL =
      getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/digester-rules.dtd")
      I think this is the problem, because when I have change it to
      getClass().getClassLoader().getResource("/org/apache/commons/digester/xmlrules/digester-rules.dtd")
      all started work correctly (i.e. DTD was obtained from commons-difester.jar).
      So, please, change it in your codebase.

        Activity

        Hide
        rdonkin@apache.org added a comment -

        Hi Sergey

        The existing resource code look ok to me and works fine on the platforms I've tested it on. The
        new code breaks. I've done a brief survey and can't find a lot of problems reported (with similar
        resource loading code).

        I'm not in favour of replacing the existing code but I would be willing to modify the code so that
        subclasses can hook in and change this behaviour.

        Could you please give some details of the platform you're using? (OS and JVM)

        (This will allow me to add some details of the problem and it's solutino to the documentation.)

        Show
        rdonkin@apache.org added a comment - Hi Sergey The existing resource code look ok to me and works fine on the platforms I've tested it on. The new code breaks. I've done a brief survey and can't find a lot of problems reported (with similar resource loading code). I'm not in favour of replacing the existing code but I would be willing to modify the code so that subclasses can hook in and change this behaviour. Could you please give some details of the platform you're using? (OS and JVM) (This will allow me to add some details of the problem and it's solutino to the documentation.)
        Hide
        Sergey Proskurnya added a comment -

        Sorry for long delay.

        After playing around with Digester, I have investigated that
        there is no real bug in its code, but instead there is a bug
        in the documentation.
        Following by examples in description to the "org.apache.commons.digester.xmlrules"
        package (Javadoc budled with commons-digester-1.5), I use the next
        DOCTYPE definition:
        <!DOCTYPE digester-rules SYSTEM "digester-rules.dtd">
        Using this DOCTYPE definition I can't get Digester to find "digester-rules.dtd",
        which is stored in commons-digester.jar.
        But after adding the known PublicId to the DOCTYPE, all things start to work!
        So, the proper DOCTYPE looks like:
        <!DOCTYPE digester-rules PUBLIC
        "-//Jakarta Apache //DTD digester-rules XML V1.0//EN"
        "digester-rules.dtd">
        Please, add this into the "org.apache.commons.digester.xmlrules" package
        description.

        Show
        Sergey Proskurnya added a comment - Sorry for long delay. After playing around with Digester, I have investigated that there is no real bug in its code, but instead there is a bug in the documentation. Following by examples in description to the "org.apache.commons.digester.xmlrules" package (Javadoc budled with commons-digester-1.5), I use the next DOCTYPE definition: <!DOCTYPE digester-rules SYSTEM "digester-rules.dtd"> Using this DOCTYPE definition I can't get Digester to find "digester-rules.dtd", which is stored in commons-digester.jar. But after adding the known PublicId to the DOCTYPE, all things start to work! So, the proper DOCTYPE looks like: <!DOCTYPE digester-rules PUBLIC "-//Jakarta Apache //DTD digester-rules XML V1.0//EN" "digester-rules.dtd"> Please, add this into the "org.apache.commons.digester.xmlrules" package description.
        Hide
        Craig McClanahan added a comment -

        Fixed in nightly build 20040215. Documentation was updated to describe the
        required DOCTYPE declaration.

        Show
        Craig McClanahan added a comment - Fixed in nightly build 20040215. Documentation was updated to describe the required DOCTYPE declaration.

          People

          • Assignee:
            Unassigned
            Reporter:
            Sergey Proskurnya
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development