Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse complaining about web-app attributes

My web-app declaration in my web.xml is:

<web-app version="2.4"
         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_4.xsd" >

And eclipse complains about all 4 attributes, here is one Eclipse complaint:

Attribute "version" must be declared for element type "web-app"

Why is Eclipse complaining about these attributes? Am I doing something wrong here?

like image 982
Mark Kadlec Avatar asked Jul 09 '11 19:07

Mark Kadlec


5 Answers

Remove the DOCTYPE line, that is what the xsd is meant to replace. I had the same issue and only this had worked.

like image 88
Ondrej Tokar Avatar answered Oct 31 '22 02:10

Ondrej Tokar


I had the same problem. I tried a different schema location and it worked for me. Instead of

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

try using this

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd

Also, set the version as "3.0".

like image 20
Arif Hossain Avatar answered Oct 31 '22 01:10

Arif Hossain


Try to put in this way:

<web-app  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_4.xsd"   version="2.4" >

Eclipse validator is very strict with the order.

like image 30
nachoorme Avatar answered Oct 31 '22 02:10

nachoorme


Didn't you forget this row in your xml file?:

    <?xml version="1.0" encoding="ISO-8859-1"?>

Your file should start like this:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app 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" version="2.5">

If it doesn't work clean and refresh your project.

like image 4
Anastasia Abramova Avatar answered Oct 31 '22 02:10

Anastasia Abramova


I changed the declaration from

http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd">

to the following and it worked like charm. Now no errors shown in web.xml

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

like image 4
mannedear Avatar answered Oct 31 '22 02:10

mannedear