2012-11-07 8 views
6

ehcacheとXSDのファイルをehcache.xmlに指しているときに、http://ehcache.org/ehcache.xsdにすべての問題は解決しました。 しかし、私たちのサーバは外部のウェブサイトにアクセスすることができませんので、以下のようにXSDの場所をローカルに変更しましたが、アプリケーションは次の例外(ehcache.xmlと同じようにehcache.xsdをクラスフォルダにコピーしています) 私は多くの解決策を見つけましたが、まだ修正することはできません。これについてあなたの助けが必要です。どうもありがとうございました。SpringでEhCacheにlocal xsdを使用する方法

春:3.1.0 にehcache:2.4.2は サーバ:Tomcatの6.0 のJava:1.6

設定:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="ehcache.xsd" 
    updateCheck="false" monitoring="autodetect" dynamicConfig="true"> 

例外:

2012-11-07 16:54:42,003 WARN [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Ignored XML validation warning> 
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'ehcache.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) 
    at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2440) 
    ... more 
2012-11-07 16:54:42,007 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed> 
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 3 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ehcache.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'. 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) 
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) 
    ... more 
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'. 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) 

    ... more 
+0

http://www.ehcache.org/ehcache.xsd – OhadR

答えて

1

私の回避策が追加されこのxsdファイルを絶対パス(c:/ehcache.xsdなど)に変換し、ehcache.xmlのこの場所をポイントします。 これは、同じ問題に直面している人に役立つことを願っています。

まだ他の解決策を探しています。

ありがとうございました。

7

通常、私はxsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"を設定しますが、これはオフライン環境では機能しません。

9

ehcache.xsdをダウンロードして、config xmlファイルと同じフォルダに置きます。 はクラスパスプレフィックスに気づく、以下のようなXMLヘッドを変更します。

<ehcache 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="classpath:ehcache.xsd"> 

これは、開発・生産環境で動作します。

+0

同じディレクトリ内にある場合、これは 'classpath:'接頭辞なしでも機能します。タンクス – msangel

関連する問題