2011-03-29 45 views
1

我使用的是日食,当我尝试运行在开发模式我的春天GWT应用解析applicationContext.xml文件时,我得到以下异常:XML错误运行时,在开发模式弹簧GWT应用

Ignored XML validation warning 
    org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. 
     at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
     at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96) 
     at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380) 
     at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) 
(...) 
Context initialization failed 
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 51 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'. 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) 

而且我applicationContext.xml文件开头是这样的:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

(...) 线51 ---><tx:annotation-driven transaction-manager="transactionManager"/>

是否任意子呃知道发生了什么?

回答

1

检查您的类路径中是否存在spring-tx依赖项(或任何其他弹簧依赖项)以使用它的模式。所有引用的模式都应该映射到一个spring依赖项。

的xmlns:TX = “http://www.springframework.org/schema/tx”

检查:

http://www.dashaun.com/2010/03/10/springframework-applicationcontext-woes-unable-to-locate-spring-namespacehandler/

+0

你知道,我有一个这样的问题,几个星期前,这个来自Spring的。我最终做的是从POM开始:(我认为你的POM存在问题(我有一个问题),也许你的maven-war-plugin正确地导出了所有的.jar文件,但你的gwt插件不能。指出你的战争目标,并建立目录,看看他们是否得到spring-tx。希望你找到自己的方式! – 2011-03-30 14:55:41

+0

你能告诉我究竟在哪里以及我要检查什么吗?因为我认为为了在开发模式下运行它,没有必要创造一场战争(那个,或者我看不到任何地方!) 感谢您的帮助,并为我的新手问题感到抱歉! – Neets 2011-03-30 15:21:36

0

实测值替代方法:

运行时GWT DEVMODE ,启动spring appcontext时出现问题, 找不到tx ... xsd。这与在该DEVMODE类GWT的定义 的类加载器,它委托给systemclassloader (码头的覆盖) 见:http://groups.google.com/group/google-web-toolkit/browse_thread/thread/ac495ee6605d21b4

这仅限定这是需要 处理在弹簧的标签时,会发生@交易的交易注释。 解决它的唯一方法是找到(在2天后),在stacktrace中查找哪个类的Spring调用了xerces(因为它是找不到该文件的xerces)。这是“DefaultDocumentLoader” 这个类在spring-beans.jar中。 =>所以我所做的是,我将spring-tx.jar中的所有类复制到新的spring-beans.jar中 ,这些类将由相同的类加载器加载 然后我还合并了META-INF/spring。处理程序,spring.schemas,spring.tooling文件, 所有现在在我创建的新jar:spring-beans-tx-3.0.5.RELEASE.jar 这个新的jar是我的项目的类路径中的第一个。 在这种情况下,它的工作原理!

相关问题