【问题标题】:web-app_2_5.xsd showing errors when validating web.xml in eclipseweb-app_2_5.xsd 在 Eclipse 中验证 web.xml 时显示错误
【发布时间】:2017-06-14 00:30:21
【问题描述】:

我不知道我能做些什么来导致这种情况,因为我花在编程上的时间已经很长了,而且我已经忘记了我可能做了什么。但是现在当我加载 Eclipse 时,它​​会说:

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.

我的前几行 web.xml 看起来像这样。

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

我了解到这可能是从中检索文件的服务器或缓存出现错误。我已经禁用并清除了缓存,据我所知,服务器与其他人正在使用的服务器相同,除非他们切换到 oracle.com url,但我还没有找到它。

任何想法将不胜感激。

【问题讨论】:

  • @Kev:也许我错过了什么,但这个问题与地理有什么关系?
  • @MichaelScheper - 阅读完整的关闭原因和接受的答案 - “特定时间”。这是一个特定于很短时间的问题,当时 Oracle 暂时破坏了托管 Eclipse 所依赖的各种 XML 模式的服务器。
  • @Kev:很公平。然而,我昨天遇到了同样的问题,我发现这篇文章很有帮助。它提示网络连接问题,结果证明是正确的,尽管该错误暗示存在格式问题。
  • @Kev 今天这里的问答帮助了我。
  • 其他以前的 Sun Microsystems 架构 url 仍然存在问题,例如java.sun.com/xml/ns/j2eejava.sun.com/xml/ns/j2ee/web-app_2_4.xsd

标签: java xml jakarta-ee


【解决方案1】:

Andrew,恐怕您的命名空间不正确。我认为 2.5 版本应该在 javaee 命名空间下(JDK、Java 1.5 和 1.6),而不是 j2ee(J2SDK、Java 1.4)。

所以替换

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

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

【讨论】:

【解决方案2】:

http://www.reddit.com/r/programming/comments/f9sxu。问题又是甲骨文。 我无法在连接到 Internet 的 SGES 2.1.1 上进行部署。当我关闭它时,部署很慢,但成功了。验证器似乎试图刷新缓存的模式并从 schemaLocation URL 下载它们。

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

但是没有这样的架构!

我会尝试找到一些好的解决方案,但最好的办法是在 Oracle 中打人……

编辑:此时已修复(27.1.2010,20:00 CET),Oracle 返回架构 - 您可以使用 wget 检查它。浏览器被重定向到文档。不错:-)

【讨论】:

【解决方案3】:

请查看您的 web.xml

是否有任何 ´&´ 符号,它们 不是 后跟一个已知的 XML 实体? &amp;uuml; 是 HTML 实体,不是 XML 实体。

【讨论】:

    【解决方案4】:

    或编写自己的实体解析器,在本地查找这些实体

    例如,在休眠的情况下,以正确的方式指向模式位置就足够了: hibernate的DTDEntityResolver摘录

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

    如果是eclipse,可以在:Preferences-->XML-->XML Catalog中指向本地xsd。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-08
      • 2012-05-18
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 2011-09-03
      • 1970-01-01
      相关资源
      最近更新 更多