views:

11428

answers:

4

The top of my web.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<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_5.xsd"
    version="2.5">

But I still get the warning from Eclipse (Ganymede) that no xml schema is detected, and schema violations are not being warned about. Other xml files in my project (spring config files for example) don't have the warning and do give correct warnings about schema violations.

How do I get the schema checking working and hopefully the warning to go away? The server does run correctly. It just appears to be an IDE issue.

+5  A: 

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

toolkit
A: 

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"&gt;

??? = 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>...

PHP-Rocks
The file is a web.xml, not an xhtml file.
Brian Deacon
+4  A: 

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".

alt text

monzonj
A: 

Similar to what was suggested in a previous answer, the namespace location changed with web-app version 2.5. All of the namespace URLs need to be modified from j2ee to javaee.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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"&gt;
Richard L.