3 Replies Latest reply on Oct 9, 2007 2:51 AM by maxandersen

    Ambiguous error with web.xml adding JSF

    gghart

      I'm wondering if there is some reason the error below is reported like this; or if I should file a feature request to get something more specific reported instead?

      --

      Wizard for adding JSF capabilities to a project can report a misleading error message for web.xml files that makes it hard for users to correct the issue. The error could be made much clearer (example follows). You get here by right-clicking on a project and selecting Red Hat Developer Studio -> Add JSF Capabilities....; it is the first window that appears.


      Consider a project with an existing (and working) web-xml file which is considered INVALID by the JSF wizard:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE web-app
       PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
       "http://java.sun.com/dtd/web-app_2_2.dtd">
      <web-app>
       <servlet>
       <servlet-name>DummyServlet</servlet-name>
       <servlet-class>dummy.class</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>DummyServlet</servlet-name>
       <url-pattern>myWebPage</url-pattern>
       </servlet-mapping>
      </web-app>


      1.0.0 Beta2 reports the following error:
      "Web descriptor file is corrupted : Element type "web-app" must be declared.:6:10."

      The problem appears to be related to the doc-type/DTD field, and if I change the version to 2.3, it accepts the web.xml file:

      <!DOCTYPE web-app
       PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">


      If the error said the DOCTYPE was invalid (and why) rather than web-app was missing, it would be a lot more helpful to track down errors.

        • 1. Re: Ambiguous error with web.xml adding JSF
          maxandersen

          well it was invalid according to the version that was specified...

          this is afaik just WTP's xml validation reporting an error according to the DTD you have in your existing file.

          • 2. Re: Ambiguous error with web.xml adding JSF
            gghart

            Hi,

            I can half-agree with you on that. When I look more closely, I see that Sun put the 2.2 and 2.3 versions of that DTD in totally different paths. As a result, the 2.2 version was pointing at nothing while the 2.3 version pointed at a real DTD file. The 2.2 version should have been pointing to this URL:

            <!DOCTYPE web-app
             PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
             "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">


            Nonetheless, when I specified the wrong DTD URL, "Web descriptor file is corrupted : Element type "web-app" must be declared.:6:10." is not a terribly descriptive error if it is trying to say the DTD can't be found.

            Just for fun, I fixed that reference to the 2.2 DTD to point at the correct URL as noted above. When I test that file in Dreamweaver, it reports the XML is valid. When I right-click and validate it in RHDS, it also reports it is valid, and when I run the JSF tool, it still reports the same error.

            ... which all leads me to wonder what the JSF parser is actually looking for?

            • 3. Re: Ambiguous error with web.xml adding JSF
              maxandersen

              report it in jira with examples of the files failing/working. thanks.