iteye_8573 2009-03-10 09:08
浏览 288
已采纳

springmodules使用ehcache却报Failed to read schema doc!

网上找到和相同错误的实例如下:

http://forum.springframework.org/showthread.php?t=44244

大概的错误应该是指http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd地址找不到,要指向本地springmodules-ehcache.jar吧?我按照http://www.jroller.com/habuma/entry/fixing_spring_modules_xsd_errors
博文的解决方法做了,但却没用啊!在xml catalog中user specified entries下设置:

[code="java"]
Location: org\springmodules\cache\config\ehcache\springmodules-ehcache.xsd in jar file F:\mysoft\spring-modules-0.9\spring-modules-0.9\spring-modules-cache.jar
URI: jar:file:F:/mysoft/spring-modules-0.9/spring-modules-0.9/spring-modules-cache.jar!/org/springmodules/cache/config/ehcache/springmodules-ehcache.xsd
Key Type: Schema Location
Key: http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
[/code]

[code="java"]Location: org\springmodules\cache\config\springmodules-cache.xsd in jar file F:\mysoft\spring-modules-0.9\spring-modules-0.9\spring-modules-cache.jar
URI: jar:file:F:/mysoft/spring-modules-0.9/spring-modules-0.9/spring-modules-cache.jar!/org/springmodules/cache/config/springmodules-cache.xsd
Key Type: Schema Location
Key: http://www.springmodules.org/schema/cache/springmodules-cache.xsd
[/code]

希望大侠能帮下忙!!

首先我的spring的配置文件如下:

[code="xml"]
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xmlns:dwra="http://www.directwebremoting.org/schema/spring-dwr-annotations"
xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd
http://www.directwebremoting.org/schema/spring-dwr-annotations http://www.directwebremoting.org/schema/spring-dwr-annotations.xsd
http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
">
...

[/code]

所报异常如下:

[code="java"]
344 [main] DEBUG org.springframework.beans.factory.xml.PluggableSchemaResolver - Trying to resolve XML entity with public id [null] and system id [http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd]
21329 [main] WARN org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springmodules.org/schema/cache/springmodules-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.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:2540)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:1836)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:531)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2408)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1753)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:705)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2740)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:225)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:423)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:353)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at co.ehcache.test.testrant(test.java:18)
at co.ehcache.test.main(test.java:15)
[/code]
[b]问题补充:[/b]
谢谢你提供的答案,很奇怪为什么当我用你的配置文件时不会出错,而用了下面方式就报异常呢?
[code="java"]

[/code]
当我把上面代码去掉也可以正常运行,不解

  • 写回答

1条回答 默认 最新

  • iteye_13779 2009-03-10 11:16
    关注

    [code="java"]<?xml version="1.0" encoding="UTF-8"?>
    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"
    xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springmodules.org/schema/ehcache http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd">

        <!-- Spring Modules Cache -->
    <bean id="cacheManager"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation">
            <value>classpath:ehcache.xml</value>
        </property>
    </bean>
    <bean id="cacheProviderFacade"
        class="org.springmodules.cache.provider.ehcache.EhCacheFacade">
        <property name="cacheManager" ref="cacheManager" />
    </bean>
    <bean id="cachingListener"
        class="mtdc.airport.vip.util.CacheListener" />
    <bean id="cachingInterceptor"
        class="org.springmodules.cache.interceptor.caching.MethodMapCachingInterceptor">
        <property name="cacheProviderFacade" ref="cacheProviderFacade" />
        <property name="cachingListeners">
            <list>
                <ref bean="cachingListener" />
            </list>
        </property>
        <property name="cachingModels">
            <props>
                <prop
                    key="mtdc.airport.vip.facade.ISystemManageFacade.get*">
                    cacheName=SYS_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISecurityFacade.get*">
                    cacheName=SECURITY_INFO
                </prop>
            </props>
        </property>
    </bean>
    <bean id="flushingInterceptor"
        class="org.springmodules.cache.interceptor.flush.MethodMapFlushingInterceptor">
        <property name="cacheProviderFacade" ref="cacheProviderFacade" />
        <property name="flushingModels">
            <props>
                <prop
                    key="mtdc.airport.vip.facade.ISystemManageFacade.add*">
                    cacheNames=SYS_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISystemManageFacade.delete*">
                    cacheNames=SYS_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISystemManageFacade.update*">
                    cacheNames=SYS_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISecurityFacade.add*">
                    cacheNames=SECURITY_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISecurityFacade.update*">
                    cacheNames=SECURITY_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISecurityFacade.delete*">
                    cacheNames=SECURITY_INFO
                </prop>
                <prop
                    key="mtdc.airport.vip.facade.ISecurityFacade.remove*">
                    cacheNames=SECURITY_INFO
                </prop>
            </props>
        </property>
    </bean>
    <bean
        class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
            <list>
                <idref bean="sysManageFacadeImpl" />
                <idref bean="securityFacadeImpl" />
            </list>
        </property>
    
        <property name="interceptorNames">
            <list>
                <value>cachingInterceptor</value>
                <value>flushingInterceptor</value>
            </list>
        </property>
    </bean>
    

    [/code]这是我的写法,可以运行的,ehcache.xml要自己提供在src文件下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?