[jdom-interest] jdom and jdk1.4: EntityResolver no longer called

abrighto at netscape.net abrighto at netscape.net
Sat Feb 16 14:52:57 PST 2002

Hi all,

The new jdk1.4 runtime library now contains the org.xml packages, 
which kind of forces you to use them, it seems (I was previously 
using xerces.jar).

Since upgrading to jdk1.4, I am having problems with DTDs not being
resolved. The problem is that the EntityResolver is not being called.
The error message is then:

 "Relative URI "UIInfo.dtd"; can not be resolved without a base URI"

Here is the related code. Any ideas on how to make this work with jdk1.4?

    /** Parse the XML document */
    private static void _parseDocument(BufferedReader in) {
    SAXBuilder builder = new SAXBuilder(true);
    builder.setEntityResolver(new EntityResolver() {
        public  InputSource resolveEntity (String publicId, String systemId) {
            URL url = Resources.getResource("UIInfo.dtd");
            try {
            return new InputSource(url.openStream());
            catch(Exception e) {
            throw new RuntimeException("Error resolving entity: " + 
                           publicId + ": " + e.toString());

    try {
        Document doc = builder.build(in); 
        Element rootElement = doc.getRootElement();
        Iterator it = rootElement.getChildren().listIterator();
        while(it.hasNext()) {
        Element e = (Element)it.next();
    catch (JDOMException ex) {
        throw new RuntimeException("Error reading " + XML_FILE + ": " + ex.getMessage());

Allan Brighton


Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop at Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

More information about the jdom-interest mailing list