web-app_2_5.xsd showing errors when validating web

2020-07-02 08:46发布

问题:

I have no idea what I could've done to cause this because my time spent programming is stretched out and I've already forgotten what I might've done. But now when I load Eclipse it says:

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. 
s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'JDK 6 XML-related APIs'.
The entity name must immediately follow the '&' in the entity reference.

My first few lines of web.xml looks like so.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">

I've read that it could be an error with the server where the file is being retrieved from, or with caching. I've disabled and cleared the cache and as far as I can tell the server is the same everyone else is using unless they switched to an oracle.com url and I haven't found it yet.

Any thoughts would be greatly appreciated.

回答1:

See http://www.reddit.com/r/programming/comments/f9sxu . The problem is Oracle, again. I cannot deploy on SGES 2.1.1 with the connection to the internet. When I turned it off, deploy was slow, but successful. It seems the validator tries to refresh cached schemas and to download them from the schemaLocation URLs.

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
GET /xml/ns/javaee/web-app_2_5.xsd ... 
HTTP/1.1 301 Moved Permanently to Location: 
  http://download.oracle.com/javase/6/docs/technotes/guides/xml/index.html

But there is no such schema!

I will try to find some good solution, but the best is maybe to punch up someone in Oracle ...

EDIT: It is fixed at this time (27.1.2010, 20:00 CET), Oracle returns the schema - you can check it with wget. Browsers are redirected to docs. Nice :-)



回答2:

Andrew, I'm afraid that your namespace is not correct. I think that version 2.5 should be under javaee namespace (JDK, Java 1.5 and 1.6), not j2ee (J2SDK, Java 1.4).

So replace

http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd

with

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd


回答3:

Please take a look at your web.xml

Are there any ´&´-signs, which are not followed by an known XML-Entity? &uuml; are HTML-Entities, not XML-Entites.



回答4:

or write own entity resolver that will lookup those entities locally

in case, for example, hibernate, it is enough to point schema location in proper way: excerpt of hibernate's DTDEntityResolver

private static final String USER_NAMESPACE = "classpath://";
 ...
public InputSource resolveEntity(String publicId, String systemId) {
 ...
else if ( systemId.startsWith( USER_NAMESPACE ) ) {
...

in case of eclipse, you can point to local xsd in: Preferences-->XML-->XML Catalog.