6 Replies Latest reply on Feb 18, 2002 11:30 AM by Adrian Brock

    Cannot resolve dtd

    Fanny Newbie


      I am using JBoss-2.4.4/Tomcat-4.0.1 and I would like to deploy struts to this environment.

      Since my machine does not have the internet access, I put all the dtd files which are required by struts in a .war file and deploy it in JBoss.

      After that, I got the following errors and the JBoss stop loading.

      [INFO,Default] resolveEntity('-Apache Software Foundation//DTD Struts Configuration 1.0//EN', 'http://localhost/struts/dtd/struts-config_1_0.dtd')
      [INFO,Default] Not registered, use system identifier

      Any help is appreciated.

      Thanks in advance.


        • 1. Re: Cannot resolve dtd
          Adrian Brock Master

          JBoss has its own local resolver, but the entities
          are "hard-coded".

          The source is org.jboss.metadata.XmlFileLoader
          if you want to modify it.

          Maybe you could provide a patch that loads the
          entities from a configuration file, or failing that
          put it in the feature requests on sourceforge.

          NOTE: This also has to work with the external verifier.
          Look at jboss/external/metadata.jar


          • 2. Re: Cannot resolve dtd
            Fanny Newbie


            Since I need it quite urgently, can you give me some hints/clues if I want to modify the XmlFileLoader. How hard is it?


            • 3. Re: Cannot resolve dtd
              Adrian Brock Master

              It is a static list of entity/dtd strings in the code.
              The real DTD has to be in the classpath of the server,
              e.g. put it in a jar and drop it in lib/ext

              Here's the code from org.jboss.metadata.XmlFileLoader in

              // Inner classes -------------------------------------------------
              * Local entity resolver to handle J2EE DTDs. With this a http connection
              * to sun is not needed during deployment.
              * Function boolean hadDTD() is here to avoid validation errors in
              * descriptors that do not have a DOCTYPE declaration.
              * @author Wolfgang Werner
              * @author Darius Davidavicius
              private static class LocalResolver implements EntityResolver
              private Hashtable dtds = new Hashtable();
              private boolean hasDTD = false;

              public LocalResolver() {
              registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN", "ejb-jar.dtd");
              registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN", "ejb-jar_2_0.dtd");
              registerDTD("-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN", "application_1_2.dtd");
              registerDTD("-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN", "application_1_3.dtd");
              registerDTD("-//Sun Microsystems, Inc.//DTD Connector 1.0//EN", "connector_1_0.dtd");
              registerDTD("-//JBoss//DTD JAWS//EN", "jaws.dtd");
              registerDTD("-//JBoss//DTD JAWS 2.4//EN", "jaws_2_4.dtd");
              registerDTD("-//JBoss//DTD JAWS 3.0//EN", "jaws_3_0.dtd");
              registerDTD("-//JBoss//DTD JBOSS//EN","jboss.dtd");
              registerDTD("-//JBoss//DTD JBOSS 2.4//EN","jboss_2_4.dtd");
              registerDTD("-//JBoss//DTD JBOSS 3.0//EN","jboss_3_0.dtd");
              registerDTD("-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN",

              Registers available DTDs
              @param String publicId - Public ID of DTD
              @param String dtdFileName - the file name of DTD
              public void registerDTD(String publicId, String dtdFileName) {
              dtds.put(publicId, dtdFileName);

              Returns DTD inputSource. Is DTD was found in the hashtable and inputSource was created
              flad hasDTD is ser to true.
              @param String publicId - Public ID of DTD
              @param String dtdFileName - the file name of DTD
              @return InputSource of DTD
              public InputSource resolveEntity (String publicId, String systemId)
              hasDTD = false;
              String dtd = (String)dtds.get(publicId);

              if (dtd != null)
              hasDTD = true;
              InputStream dtdStream = getClass().getResourceAsStream(dtd);
              InputSource aInputSource = new InputSource(dtdStream);
              return aInputSource;
              } catch( Exception ex ) {
              // ignore
              return null;

              Returns the boolean value to inform id DTD was found in the XML file or not
              @return boolean - true if DTD was found in XML
              public boolean hasDTD ()
              return hasDTD;



              • 4. Re: Cannot resolve dtd
                Fanny Newbie


                Thanks for your reply.

                If I need to refer a dtd which is not included in the LocalResolver, do I need to modify the XmlFileLoader?

                For example:

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



                • 5. Re: Cannot resolve dtd
                  Joe Newbie

                  Hi Adrian,

                  I followed your advice and do a quick hack registering the struts dtd that I used. However when I tried it out I noticed that the resolveEntity method is only used to resolve those Sun's DTDs. Application dtds in application xmls are not resolved by this class. Any other ideas?

                  - Joe

                  • 6. Re: Cannot resolve dtd
                    Adrian Brock Master

                    I never said this would magically get used.

                    The class org.jboss.metadata.XmlFileLoader is
                    used during JBoss deployment. It has a local resolver for
                    redirecting entities to dtds in the classpath.

                    You can use this class in your own code, providing
                    you modify the list of registerDTD()s and add the dtd
                    to the classpath.

                    registerDTD("-//Apache Software Foundation//DTD Struts Configuration 1.0//EN", "struts-config_1_0.dtd");

                    To put struts-config_1_0.dtd in the classpath,
                    create a jar containing the dtd and drop it in jboss/lib/ext.

                    Because of the confusion, I think this mechanism is
                    not very useful for struts???
                    I haven't used struts.
                    Perhaps you can explain how the dtd is used?