On Nov 28, 2005, at 10:22 AM, Wendy Smoak wrote:


Hmmm... maybe we should wait for Greg to sort this all out. :)

It should _not_ be going out to retrieve the dtd, that much I know.


Ok, here's what's happening. The DigesterDefinitionsReader class is the class that reads Tiles defs using Digester in Standalone Tiles. In part, it contains the following code:

    protected String registrations[] = {
"-//Apache Software Foundation//DTD Tiles Configuration 1.1// EN",
        "/org/apache/tiles/resources/tiles-config_1_1.dtd",
"-//Apache Software Foundation//DTD Tiles Configuration 1.2// EN",
        "/org/apache/tiles/resources/tiles-config_1_2.dtd",
    };

...

    public DigesterDefinitionsReader() {
        digester = new Digester();
        digester.setValidating(validating);
        digester.setNamespaceAware(true);
        digester.setUseContextClassLoader(true);

        // Register our local copy of the DTDs that we can find
        for (int i = 0; i < registrations.length; i += 2) {
            URL url = this.getClass().getClassLoader().getResource(
                    registrations[i+1]);
            if (url != null) {
                digester.register(registrations[i], url.toString());
            }
        }
    }

The registrations array definition creates a set of Strings to pass to digester. The constructor then gets the Resource for each registration string and calls the Digester register() method to point to the DTD in the JAR instead of on the web.

The problem is that the ClassLoader cannot resolve the URL if it begins with "/". So if I change this:

    protected String registrations[] = {
"-//Apache Software Foundation//DTD Tiles Configuration 1.1// EN",
        "/org/apache/tiles/resources/tiles-config_1_1.dtd",
"-//Apache Software Foundation//DTD Tiles Configuration 1.2// EN",
        "/org/apache/tiles/resources/tiles-config_1_2.dtd",
    };

to this:

    protected String registrations[] = {
"-//Apache Software Foundation//DTD Tiles Configuration 1.1// EN",
        "org/apache/tiles/resources/tiles-config_1_1.dtd",
"-//Apache Software Foundation//DTD Tiles Configuration 1.2// EN",
        "org/apache/tiles/resources/tiles-config_1_2.dtd",
    };

it works. I can completely disconnect from any network and still resolve the DTDs. Interestingly, the problem seems to only occur when running with a JAR. If I run the original code against an exploded directory instead of a JAR it works fine. But if I JAR the code up I have to remove the leading "/" or the URL won't resolve. Any idea why that is?

Greg



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

Reply via email to