3 Replies Latest reply on Jan 23, 2007 5:04 PM by Josh Smith

    How to Turn Off DTD Validation for struts-config.xml

    Ben Wong Newbie

      Hey guys,

      I am trying to deploy a web app with struts on JBoss 3.0.7. When I am not connected to the Internet, I get the following exception on deployment:

      Parse Fatal Error at line 5 column -1: External entity not found: "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd".
      java.net.UnknownHostException: jakarta.apache.org
      at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
      at org.apache.crimson.parser.Parser2.externalParameterEntity(Parser2.java:2870)
      at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1167)
      at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
      at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)

      If I take out the DTD declaration in the struts-config.xml file, I get the following error:

      Parse Warning at line 3 column -1: Valid documents must have a <!DOCTYPE declaration.
      org.xml.sax.SAXParseException: Valid documents must have a <!DOCTYPE declaration.
      at org.apache.crimson.parser.Parser2.warning(Parser2.java:3148)

      Is there a way to configure JBoss to not have the Xerces2 parser validate against DTDs? It looks like the web.xml file seems to deploy fine even if the DTD declaration is pointing to SUN, so I am guessing the JBoss guys are doing something to handle this.

      By the way, I know I can copy the DTDs into the DTD directory and point the XML file there, but I was wondering if there are other possibly better ways.

      Any help or other suggestions would be greatly appreciated?

      Ben Wong

        • 1. Re: How to Turn Off DTD Validation for struts-config.xml

          we add local resolvers to our DTDs in code but I don't know if there's a configuration option (for instance a system property) that you can set for xerces to add your own -- you probably need to check the xerces documentation for that.

          Or if you feel like coding, add a service to JBoss that allows you to add custom resolvers, might work too...

          • 2. Re: How to Turn Off DTD Validation for struts-config.xml
            dturner Newbie

            - No need to turn off validation -

            1) You want to change the <!DOCTYPE... declaration to point to a location on the local file system.
            2) So, choose a file system location and store the dtd file there.
            3) Change your struts-config.xml file document type declaration to point to "file://the.local.file.system.location..." instead of the supplied "http://jakarta.apache.org...". See example below.

            <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

            4) This solution worked fine for a JBoss 3.0 / Tomcat 4.1 / Struts 1.1 configuration running on NT4.

            • 3. Re: How to Turn Off DTD Validation for struts-config.xml
              Josh Smith Newbie

              Is there a way to set it so that the dtd can just be deployed alongside the xml file (even inside the WEB-INF folder) and have the validation go from there?

              That way I could simply have the dtd reside alonside the xml file so that validaiton passes, and I don't have to worry about linking externally apache for example.

              I ahve tried to this locally, but all my attempts end up going nowhere as it keeps expecting to find the file in the bin directory of the JBoss instance.