The top of my web.xml
file looks like this:
I hate that warning too. Specially because it appears in XML files that you haven't written but appear in your project for whatever reason (if you use MAVEN it's hell).
With Eclipse 3.5+ you can easily remove this validation rule. Go to Preferences-->XML-->XML FILES --> Validation and Select "ignore".
You may also have to do a Project -> Clean for the validation warnings to go away.
The problem is two-fold:
When you revise to the correct values for Java EE 5, the entry in the cache will be found and Eclipse will be happy.
Add this <!DOCTYPE ...>
to your xml file. Please put it under <?xml ...>
:
<!DOCTYPE ??? PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
???
= Your root element, now if your sub-element name is using a html reserved word you might be catching some errors, all you have to do is change them to a non-reserved word.
For example:
If your current sub-element is <img>
, change it to <pic>
...
If you have the same (missleading) error message because your XML Editor was not finding the XSD file, you can add a catalog entry.
You pick the URL specified for the schema, for a declaration like
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
The URL of the schema file (http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd) is specified for the namespace http://java.sun.com/xml/ns/j2ee. You can now redirect the location of the file with the workspace catalog in Eclipse:
Preferences -> XML -> XML Catalog -> Add..
Use
Key Type = Schema Location
Key = http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
And then you can use the file chooser to pick actually a XSD file on the filesystem or the workspace.
Clear the cache for stored validation files.
Window > Preferences > General > Network Connections > Cache then remove all. Now go validate the file and see if that clears things up.
This happed to me and clearing the cache for the validation was the only way to get it functioning properly again. The advice for clearing dirty cache was found here.
Perhaps try:
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
Instead of:
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
Also, the <!DOCTYPE ...>
is missing:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- ... -->
</web-app>