Sunday, July 24, 2011

cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'

Problem :

cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'. One of '{"http://java.sun.com/xml/ns/javaee":servlet-class, "http://java.sun.com/xml/ns/javaee":jsp-file}' is 
 expected.

In Eclipse, I have the following target (display-name) in red :

web.xml :
  <servlet>
<servlet-name>monitor</servlet-name>
<display-name>monitor</display-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/monitor-servlet.xml</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
  </servlet>

Solution:

You have to put the tag display-name first.

  <servlet>
<display-name>monitor</display-name>  
<servlet-name>monitor</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/monitor-servlet.xml</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
  </servlet>

Note : In my google project http://code.google.com/p/lin-mon-webapp/, I have committed a web.xml with no validation error (I just make right click to be sure not having validation error)

2 comments: