web app web.xml error

25,586

Solution 1

I deleted the file and pasted the text from the old one into a new file with the same name and now there's no errors.

Solution 2

well, as per new format of DTD web-app tag might contains following tags. <!ELEMENT web-app (icon?, display-name?, description?, distributable?, context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*, login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>

above mentioned icon, display-name, description, distributable....etc are in the same order as they have mentioned in the DTD file.

e.g. if you put description tag before display-name it gives error.

Solution 3

Just for a reference: A SelectAll->Cut->Save->Paste->Save also fixes the problem. Probably there is a line ending character issue.

Solution 4

I followed the suggestion for "copy all" - "cut" - "paste" - "save" and this seemed to clear up the message. I found that in the "pasted" version all tabs had been converted to spaces.

So it seems that the web.xml validator in Eclipse does not like tabs.

Share:
25,586
HeelToeHero
Author by

HeelToeHero

Updated on July 13, 2020

Comments

  • HeelToeHero
    HeelToeHero almost 4 years

    I am getting an error in my GWT application being developed in Eclipse. It's in the web.xml file. Here's the error:

    The content of element type "web-app" must match "(icon?,display-   name?,description?,distributable?,context-
         param*,filter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-
         file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-
         role*,env-entry*,ejb-ref*,ejb-local-ref*)".
    

    I have seen numerous posts about this and the problem is the order of the elements of the file, but that fix doesn't work for me (I have also tried putting all the <servlet-mapping> tags right after the corresponding <servlet>, it did not work either)

    My web.xml file :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    
    <web-app>
    
      <servlet>
        <servlet-name>dispatch</servlet-name>
        <servlet-class>com.yachtcloser.server.DispatchServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet>
        <servlet-name>upload</servlet-name>
        <servlet-class>com.yachtcloser.server.UploadServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet> 
    
      <servlet>
        <servlet-name>download</servlet-name>
        <servlet-class>com.yachtcloser.server.DownloadServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet>
        <servlet-name>login</servlet-name>
        <servlet-class>com.yachtcloser.server.LoginServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet-mapping>
        <servlet-name>dispatch</servlet-name>
        <url-pattern>/dispatch.do</url-pattern>
      </servlet-mapping>
    
      <servlet-mapping>
        <servlet-name>upload</servlet-name>
        <url-pattern>/upload.do</url-pattern>
      </servlet-mapping>
    
      <servlet-mapping>
        <servlet-name>download</servlet-name>
        <url-pattern>/download.do</url-pattern>
      </servlet-mapping>
    
      <servlet-mapping>
        <servlet-name>login</servlet-name>
        <url-pattern>/login.do</url-pattern>
      </servlet-mapping>
    
      <!-- Default page to serve -->
      <welcome-file-list>
        <welcome-file>Yc.html</welcome-file>
      </welcome-file-list>
    
    </web-app>
    

    Are there any other ways of tracking this error; other files that are linked to this?

  • Marcx
    Marcx about 11 years
    I had this problem, and thanks to you I solved, the problem was in a bad order of elements...
  • vdwijngaert
    vdwijngaert over 10 years
    In Eclipse, you can also re-format the code using CTRL+SHIFT+F (or by going to source > format). That should also clear out any formatting issues.
  • Scriptable
    Scriptable over 9 years
    This answer seems irrelevant, the quesion was asked 3 years ago and the issue seems to be related to line endings or something similar. Not the order of the elements.
  • Cnu
    Cnu over 9 years
    it's relevant, rather typing the whole web.xml. I have just given a view. I had the same issue, while declaring content-param, I wrote them after servlet-mapping, so I got this error. When changed the order, error went away. So It could be a possible reason.
  • Cnu
    Cnu over 9 years
    FYI, see the very first answer of this post.
  • Scriptable
    Scriptable over 9 years
    So that answer has alreay been given, so its not needed again :)
  • Cnu
    Cnu over 9 years
    I posted my experience, I though it would be use full for some one. But you are saying it's not relevant...
  • Scriptable
    Scriptable over 9 years
    I was merely saying my opinion that it doesnt seem useful, if you think it is useful then leave it there mate, just a suggestion as part of the review process.
  • srinivas
    srinivas almost 9 years
    Cut copy paste is not a permanent solution, i gone for the above one. it worked, just re arranged the order of servlet mapping and listeners. It solved.
  • umair
    umair about 8 years
    Strange but solved issue for me.
  • Chintu Karthi
    Chintu Karthi over 2 years
    Same. Strange, but worked for me as well.
  • Shakti Pravesh
    Shakti Pravesh about 2 years
    worked for me. In the process.. <?xml version="1.0" encoding="UTF-8"?> Above line got added.