facebook

Invalid web.xml generated by MyEclipse

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #248463 Reply

    Don Nelson
    Member

    When MyEclipse (Version: 4.0.0 Build id: 20060309-4.1.1-GA) generates the web.xml file for a web project,
    it puts the elements in the wrong order, and a compile error is generated. The error is

    Severity    Description    Resource    In Folder    Location    Creation Time    Id
    2    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*)".    web.xml    TestWeb/WebRoot/WEB-INF    line 33    March 13, 2006 11:49:49 AM    49084
    

    The web.xml file is:

    <?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>
      <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
      </context-param>
      <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
      </listener>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
      <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
        <init-param>
          <param-name>maxFileSize</param-name>
          <param-value>20m</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>*.jsf</url-pattern>
      </filter-mapping>
    </web-app>
    
    

    Here’s the corrected web.xml that compiles correctly:

    <?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>
      <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
      </context-param>
      <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
        <init-param>
          <param-name>maxFileSize</param-name>
          <param-value>20m</param-value>
        </init-param>
      </filter>
      <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>*.jsf</url-pattern>
      </filter-mapping>
      <listener>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
      </listener>
      <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>0</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
    </web-app>

    Notice among other things that the <servlet> and <servlet-mapping> elements are after the listener class.

    Any ideas?

    Thanks,

    Don

    #248535 Reply

    Riyad Kalla
    Member

    Don,
    This looks like a bug, thanks for the report. The code that modifies the xml file to insert the servlet elements when adding caps I do not think honors the DTD or Schema ordering.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Invalid web.xml generated by MyEclipse

You must be logged in to post in the forum log in