【问题标题】:Prevent 503 error from W3.org when Spring tries to load XML files当 Spring 尝试加载 XML 文件时,防止 W3.org 出现 503 错误
【发布时间】:2010-02-16 06:57:46
【问题描述】:

简而言之,我正在尝试学习一点 Spring。问题是,当我部署我的应用程序时,Spring 加载 XML 文件并遇到此异常:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 8 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid;
nested exception is oracle.xml.parser.schema.XSDException:
Server returned HTTP response code: 503 for URL:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
....

我发现这是由 W3 引起的,因为 W3 对下载其 DTD 文件的重复请求返回 503(有关详细信息,请参阅here)。有什么方法可以让 Spring 使用缓存版本?另外,我该怎么做呢?我的环境包括 Glassfish v3、Spring v2.5.6、Spring Web Flow v2.0.8 和 NetBeans 6.8

问题是,文件中没有提到 DTD。这是我的spring-servlet.xml 的样子:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:webflow="http://www.springframework.org/schema/webflow-config"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/webflow-config
   http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd">
....
</beans>

干杯

【问题讨论】:

    标签: java spring dtd


    【解决方案1】:

    你的 spring xml 文件不应该是 XHTML,所以只需删除 DTD 声明。 相反,使用 xml 模式,如示例中所示

    http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-metadata

    【讨论】:

    【解决方案2】:

    W3 服务器可能已关闭......但应用程序停止工作并不酷,它无法与 w3.org 通信,并且应用程序重新获取标准 DTD 等对 w3.org 不友好运行时间。

    您的应用程序应该有自己的标准 DTD 等永久存储,并且应该进行配置,以便 XML 解析器等知道首先查看那里。或者,您应该安排您的代理人拥有相关 DTD 的永久副本。

    无论如何,正如@andi5 所说,Spring 接线文件不应该使用那个特定的 DTD。所以删除引用应该可以解决这个特定的问题实例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-12
      • 2014-07-28
      • 2018-03-12
      • 1970-01-01
      • 2011-04-02
      • 2018-07-17
      • 1970-01-01
      • 2015-11-04
      相关资源
      最近更新 更多