Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
Operating System: other
Platform: Other
-
25112
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.