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?
Remove the DOCTYPE line, that is what the xsd is meant to replace. I had the same issue and only this had worked.
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"
.
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.
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.
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">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With