2011-03-29 40 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是我的項目的類路徑中的第一個。 在這種情況下,它的工作原理!

相關問題