33
<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">

Referenced file contains errors (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd). For more information, right click on the message in the Problems View and select "Show Details..."

The errors below were detected when validating the file "web-app_2_5.xsd" via the file "web.xml". In most cases these errors can be detected by validating "web-app_2_5.xsd" directly. However it is possible that errors will only occur when web-app_2_5.xsd is validated in the context of web.xml.

In details, I see a bunch of these:

s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than xs:appinfo and xs:documentation. Saw 'var _U="undefined";'

Vikdor
  • 23,934
  • 10
  • 61
  • 84
jacekn
  • 1,521
  • 5
  • 29
  • 50
  • Sometimes it is a bug in Eclipse. Take a look how to disable the validation: https://stackoverflow.com/questions/67271527/eclipse-language-servers-there-is-1-error-in-javaee-7-xsd – 30thh Dec 10 '21 at 08:43

7 Answers7

69

If you replace j2ee by javaee, it will work fine.

EDIT :

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

Edit:

To know anything further related to this error. Please follow the Link. Here you will find schemas for Java EE deployment descriptors (web.xml).

Sazzadur Rahaman
  • 6,938
  • 1
  • 30
  • 52
53

replace

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">

with

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee;http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">

The solution is that you have to put semicolon between URLs

I am sure you will not get the error again :)

demongolem
  • 9,474
  • 36
  • 90
  • 105
  • 4
    What is the reasoning to do this? The error did go away, but I don't know what will be side effects – Wand Maker Jul 03 '13 at 13:23
  • 1
    When I use this declaration, the validator says that "Cannot find the declaration of element'web-app'" – Ronye Vernaes Mar 20 '15 at 18:51
  • After adding a semicolon in my case (is a faces-config) the error (not on my mac eclipse only in my linux eclipse) went away but got a warning message: no grammar constraints (DTD or XML Schema) referenced in the document. – Kemin Zhou Jan 11 '19 at 22:28
12

I suggest you add ; between 2 passages: xsi:schemaLocation="http://java.sun.com/xml/ns/javaee and http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Like this:

:xsi:schemaLocation="http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Tot Zam
  • 8,406
  • 10
  • 51
  • 76
Thái Ngô
  • 246
  • 3
  • 3
9

Add semicolon between xsi:schemaLocation just as shown below

"http://java.sun.com/xml/ns/javaee;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

This resolved my this error in <servlet-name> tag line as well.

"cvc-id.3: A field of identity constraint 'web-common-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type."

Maitry Gohil
  • 101
  • 2
  • 8
2

In my case, I had replaced

xsi:schemaLocation="http://java.sun.com/../.."

with

xsi:schemaLocation="http://xmlns.jcp.org/../.."

Cheers!

Mohan
  • 4,755
  • 2
  • 27
  • 20
1

On the surface it appears that the schemaLocation is wrong. Resolving it appears to redirect to a HTML page rather than a XSD schema.

I would suggest simply removing this line unless you really want to do XSD validation at runtime. Bear in mind the relevant parts will be validated by your servlet container.

EdC
  • 2,309
  • 1
  • 17
  • 30
0

Replacing the schemaLocation as below has resovled the error for me:

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/j2ee; http://xmlns.jcp.org/xml/ns/j2ee/web-app_2_4.xsd"
ranka47
  • 995
  • 8
  • 25
Roshan
  • 21
  • 3