Spring Tomcat无法读取架构文档

Spring Tomcat无法读取架构文档,spring,tomcat,proxy,xml-parsing,dwr,Spring,Tomcat,Proxy,Xml Parsing,Dwr,我们正在尝试为当前项目添加DWR,执行此操作的代码如下所示: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr" xmlns:context="http://www.springfra

我们正在尝试为当前项目添加DWR,执行此操作的代码如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
       http://www.directwebremoting.org/schema/spring-dwr
       http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd">

    <context:annotation-config />
    <dwr:configuration />
    <dwr:annotation-config />
    <dwr:url-mapping />

    <dwr:controller id="dwrController" debug="true" >
        <dwr:config-param name="activeReverseAjaxEnabled" value="true"/>
    </dwr:controller>
[24 Feb 2012 17:02:17,272] WARN  [http-8040-1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored X
ML validation warning
org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 26; schema_reference.4: Failed to read schema document 'htt
p://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd', because 1) could not find the document; 2) the docu
ment could not be read; 3) the root element of the document is not <xsd:schema>.
分析错误并查看Tomcat日志时,Tomcat似乎无法读取模式文档,但只有在尝试在DWR的模式上读取时才会发生这种情况[即,并引发如下异常:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
       http://www.directwebremoting.org/schema/spring-dwr
       http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd">

    <context:annotation-config />
    <dwr:configuration />
    <dwr:annotation-config />
    <dwr:url-mapping />

    <dwr:controller id="dwrController" debug="true" >
        <dwr:config-param name="activeReverseAjaxEnabled" value="true"/>
    </dwr:controller>
[24 Feb 2012 17:02:17,272] WARN  [http-8040-1] org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored X
ML validation warning
org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 26; schema_reference.4: Failed to read schema document 'htt
p://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd', because 1) could not find the document; 2) the docu
ment could not be read; 3) the root element of the document is not <xsd:schema>.
[2012年2月24日17:02:17272]警告[http-8040-1]org.springframework.beans.factory.xml.XmlBeanDefinitionReader-忽略X
ML验证警告
org.xml.sax.SAXParseException;行号:24;列号:26;架构参考。4:读取架构文档“htt”失败
p://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd',因为1)找不到文档;2)文档
无法读取文档的根元素;3)文档的根元素不可用。
我试着用谷歌搜索一下stack overflow的答案。流行的答案来自下面的网站,说明这是一个类路径问题

让我认为这不是一个类路径问题的原因是,当我尝试在家运行时,同一个程序工作得非常好。也就是说,Tomcat能够访问和解析dwr模式,这在我看来是防火墙或代理问题。我们确实通过公司的代理访问internet。但我能够从中访问所有dwr模式我的浏览器非常好

这是一个代理问题吗?如果是的话,我如何将代理添加到Tomcat的配置中。更让我困惑的是,为什么只有DWR模式是不可访问的,而as w3.org和spring.org模式是完美工作的。
请指出我对技术方面的理解是否有缺陷。

一年前我遇到了一个DWR XML方案问题(版本3.0 M1)。它们把
spring-dwr-2.0.xsd
spring-dwr-3.0.xsd
搞得一团糟,并且没有在jar中添加3.0 xsd的spring.schema位置。--可能您也有同样的问题。但首先确保部署
dwr.jar
正确

如果
dwr.jar
不包含包含以下行的文件
META-INF\spring.schemas

http\://www.directwebremoting.org/schema/spring-dwr-3.0.xsd=org/directwebremoting/spring/spring-dwr-3.0.xsd
然后我的解决方案将帮助您。(如果
dwr.jar
包含该行,那么问题是另一行。)


为了解决这个问题,我创建了一个新的jar(
dwr xsd.jar
)文件,其中包含两个xsd文件和一个
spring.schemas
文件

要构建这样一个jar:

下载2个dwr xsd JAR(
spring-dwr-2.0.xsd
spring-dwr-3.0.xsd
),并将它们放入包
org.directwebremoting.spring

然后将此
spring.schemas
文件添加到
META-INF
目录:

 http\://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd
 http\://www.directwebremoting.org/schema/spring-dwr-3.0.xsd=org/directwebremoting/spring/spring-dwr-3.0.xsd
(文件必须有一个换行符!-我不能让它在SO中可见)


没有向您的应用程序添加
dwr xsd.jar
dwr.jar

拉尔夫:我尝试了您的解决方案,一切都像您一开始所说的那样正常,即spring.schemas映射正确。但很快我发现版本号是一个问题。只是描述整个问题,以便对其他人也有用

我在(DWR schema works)和没有internet(not work)连接的情况下尝试了相同的方法,这导致我在SO中进行了下面的讨论,这与您的答案一起也很有用

我首先看到映射不正确,我在XML for DWR中更改了bean定义,如下所示:

   http://www.directwebremoting.org/schema/spring-dwr
   http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
从现有的:

http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd">
所以有两个问题

  • “>
  • 版本从spring-dwr-3.0.xsd更改为spring-dwr-2.0.xsd
  • #1的原因似乎是META-INF中的spring.schemas文件是这样映射的

    http\://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd
    
    对于第2点,基本上是DWR jar文件(命名为DWR-3.0.M1.jar),尽管其版本表示为3.0,但只包含2.0版本的xsd,并且在spring.schemas中有适当的映射。因此,当我更改它时,它是脱机工作的[虽然我还没有检查防火墙办公室网络。但我认为当它可以离线找到内容时,它不会尝试从在线获取]


    非常感谢您的回答

    您的答案可能不是这样。但在这种情况下,请清理并重新构建。原因是,如果两个罐子退出,将采用较旧的spring jar和xsd。希望这对其他人有所帮助……一般来说,由于许多原因会抛出此异常。

    只是为了澄清您的“答案”:我的提示:“创建您自己的
    dwr-xsd.jar
    有效吗?我没有创建新的dwr-xsd.jar,而是使用上面的映射更新了旧dwr.jar文件中的xsd本身。