Invalid content was found starting with element 'display-name' in web.xml

Viewed 37541

I am using Eclipse Helios Release. Eclipse xml validator doesn't like the display-name element under <servlet> in my web.xml. Here's the relevant part:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID"
  version="2.5">

  <display-name>PropTax</display-name>
  <servlet> 
    <servlet-name>PropTax</servlet-name>     
    <display-name>PropTax</display-name> 
    <servlet-class>org.slco.treasurer.propertytax.servlet.PropTax</servlet-class>
  </servlet>
  (...)

If I remove display-name element then there is no error anymore. If I understand correctly 2.5 is the right schema to support display-name, and even context help under the editor will list display-name as part of choice.

Could anyone help me here?

Error message from Eclipse validator:

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. web.xml /PropTax/WebContent/WEB-INF line 6 XML Problem
5 Answers

change xmlns = "http://java.sun.com/xml/ns/j2ee" to xmlns="http://xmlns.jcp.org/xml/ns/javaee" and the error should go. It worked for me. or else follow convention according ot java.sun.com and add move display-name under the servlet tag.

You have to put the tag display-name first.

<servlet>
<display-name>PropTax</display-name>
<servlet-name>PropTax</servlet-name>      
<servlet-class>org.slco.treasurer.propertytax.servlet.PropTax</servlet-class>

Related