Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 715
juny fan Avatar asked Oct 20 '10 21:10

juny fan


3 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.

like image 104
Pranesh Nangare Avatar answered Sep 24 '22 07:09

Pranesh Nangare


You need to use the '101010' button to quote your XML for it to be readable.

However, according to the XSD you referenced, a servlet definition (servlet tag) needs to have the description stuff (including display-name) before the servlet-name. Given the error you've posted, I suspect you've got servlet-name followed by display-name. However, it's hard to tell without seeing the XML well formatted.

like image 45
dty Avatar answered Sep 23 '22 07:09

dty


Move "display-name" as the first element under "servlet" tag, the validation error should go away.

<servlet> 
 <display-name>PropTax</display-name> 
 <servlet-name>PropTax</servlet-name>     
 <servlet-class>org.slco.treasurer.propertytax.servlet.PropTax</servlet-class>
</servlet>
like image 22
user959740 Avatar answered Sep 24 '22 07:09

user959740