What does this web.xml error mean?
Asked Answered
C

8

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";'

Contuse answered 18/11, 2012 at 4:43 Comment(1)
Sometimes it is a bug in Eclipse. Take a look how to disable the validation: #67272027Routine
S
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).

Stogy answered 18/11, 2012 at 4:56 Comment(6)
wtf..this is annoying!Lozier
@jhohlfeld the list of schemas by release is currently here: oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html Schemas java <= 1.4 are use j2ee and schemas for >= 1.5 use javaeeMiddleweight
I have this declaration and the error is still presentDedededen
@Satzzadur Rahaman Can you explain why this is showing error?Bulbiferous
In case it is not working as for @RonyeVernaes, check out this other question: #32539254Putt
<web-app xmlns="java.sun.com/xml/ns/j2ee" xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:schemaLocation="java.sun.com/xml/ns/j2ee java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> im getting errors for thisMukund
R
54

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 :)

Rebus answered 30/5, 2013 at 13:21 Comment(3)
What is the reasoning to do this? The error did go away, but I don't know what will be side effectsMoulden
When I use this declaration, the validator says that "Cannot find the declaration of element'web-app'"Dedededen
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.Miltonmilty
S
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">
Sculpture answered 11/9, 2017 at 17:53 Comment(0)
S
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."

Shanell answered 4/7, 2021 at 18:57 Comment(0)
K
2

In my case, I had replaced

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

with

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

Cheers!

Kala answered 22/4, 2017 at 7:23 Comment(0)
G
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.

Gulp answered 18/11, 2012 at 4:52 Comment(0)
V
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"
V2 answered 11/2, 2021 at 13:27 Comment(0)
C
0

In case my solution is helpful for anyone. My problem was similar (same error although for a different XSD) and I have posted my solution to this also similar question: https://mcmap.net/q/452206/-eclipse-web-xml-quot-referenced-file-contains-errors-quot-duplicate.

Counterclockwise answered 24/2 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.