`
阅读更多

shiro ehcache缺少配置报错

 

================================

©Copyright 蕃薯耀 2019年8月6日

http://fanshuyao.iteye.com/

 

一、问题描述

 

Spring整合Shiro使用ehcache,报错:

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:

PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'realms' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.

 

具体如下:

八月 02, 2019 2:20:01 下午 org.apache.catalina.core.StandardContext listenerStart
严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [spring.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'realms' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1534)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1281)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:237)
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5143)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:932)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [spring.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'realms' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1571)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1281)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	... 45 more
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'realms' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Caches cannot be added by name when default cache config is not specified in the config. Please add a default cache config in the configuration.
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1567)
	... 53 more

 

二、解决方案

从错误来分析,是ehcache缺少了默认的配置,加上就好。

 

ehcache.xml默认的配置:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">  

<defaultCache    
    maxElementsInMemory="10000"    
    maxElementsOnDisk="0"    
    eternal="true"    
    overflowToDisk="true"    
    diskPersistent="false"    
    timeToIdleSeconds="0"    
    timeToLiveSeconds="0"    
    diskSpoolBufferSizeMB="50"    
    diskExpiryThreadIntervalSeconds="120"    
    memoryStoreEvictionPolicy="LFU"    
    />
    
    
</ehcache>

 

 

 

================================

©Copyright 蕃薯耀 2019年8月6日

http://fanshuyao.iteye.com/

 

 

 

1
0
分享到:
评论
1 楼 蕃薯耀 2019-08-06  
shiro ehcache缺少配置报错
shiro ehcache出错
ehcache PropertyAccessExceptions
Please add a default cache config in the configuration.

===============
蕃薯耀

相关推荐

    SpringMVC+Mybatis+Spring+Shiro+ehcache整合配置文件

    接着,配置Shiro的安全管理,定义 Realm 对象进行认证和授权,结合Ehcache实现缓存策略。最后,通过Spring的AOP支持,将Shiro的拦截器添加到Spring的全局拦截器链中,实现安全控制。 这样的整合可以创建一个健壮、...

    shiro-ehcache-1.4.0-API文档-中文版.zip

    赠送jar包:shiro-ehcache-1.4.0.jar; 赠送原API文档:shiro-ehcache-1.4.0-javadoc.jar; 赠送源代码:shiro-ehcache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.4.0.pom; 包含翻译后的API文档...

    shiro-ehcache-1.3.2-API文档-中英对照版.zip

    赠送jar包:shiro-ehcache-1.3.2.jar; 赠送原API文档:shiro-ehcache-1.3.2-javadoc.jar; 赠送源代码:shiro-ehcache-1.3.2-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.3.2.pom; 包含翻译后的API文档...

    shiro-demo使用ehcache做缓存.zip

    在这个“shiro-demo使用ehcache做缓存”的示例中,我们将深入探讨如何结合Apache Shiro和 Ehcache 实现高效的缓存管理。 Ehcache 是一个广泛使用的开源Java缓存解决方案,它提供了内存和磁盘存储,以及对缓存数据的...

    spring+shiro+ehcache例子

    在web.xml中配置shiro过滤器 4:项目post乱码处理 在web.xml中配置字符过滤器 5:项目运行信息查看 在web.xml中配置log4j信息打印 (需要自己将log4j的配置文件给打开) 三: 配置文件 查看/src/config/ ...

    shiro-ehcache-1.2.3-API文档-中英对照版.zip

    赠送jar包:shiro-ehcache-1.2.3.jar; 赠送原API文档:shiro-ehcache-1.2.3-javadoc.jar; 赠送源代码:shiro-ehcache-1.2.3-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.2.3.pom; 包含翻译后的API文档...

    shiro-ehcache

    2. 配置Shiro:在Shiro的配置文件(如`shiro.ini`或XML配置)中,指定使用Ehcache作为缓存管理器。这通常涉及到配置`cacheManager`元素,指定为`ehcache`类型,并指定Ehcache的配置文件位置。 ```ini [main] ...

    Ehcache缓存框架整合Spring和shiro权限配置

    缓存可以提高查询数据性能, 对同一批数据进行多次查询时, 第一次查询走数据库, 查询数据后,将数据保存在内存中,第二次以后查询 可以直接从内存获取数据,而不需要 和数据库进行交互。

    shiro-ehcache-1.2.3-API文档-中文版.zip

    赠送jar包:shiro-ehcache-1.2.3.jar; 赠送原API文档:shiro-ehcache-1.2.3-javadoc.jar; 赠送源代码:shiro-ehcache-1.2.3-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.2.3.pom; 包含翻译后的API文档...

    shiro-ehcache-1.3.2-API文档-中文版.zip

    赠送jar包:shiro-ehcache-1.3.2.jar; 赠送原API文档:shiro-ehcache-1.3.2-javadoc.jar; 赠送源代码:shiro-ehcache-1.3.2-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.3.2.pom; 包含翻译后的API文档...

    shiro-ehcache-1.4.0-API文档-中英对照版.zip

    赠送jar包:shiro-ehcache-1.4.0.jar; 赠送原API文档:shiro-ehcache-1.4.0-javadoc.jar; 赠送源代码:shiro-ehcache-1.4.0-sources.jar; 赠送Maven依赖信息文件:shiro-ehcache-1.4.0.pom; 包含翻译后的API文档...

    shiro-ehcache-1.2.0.jar

    shiro-ehcache-1.2.0.jar

    shiro-ehcache.xml

    在maven项目中,此shiro-ehcache.xml配置文件放在resources下,在applicationContext.xml中,用于shiro缓存管理器所配置,然后给shiro安全管理器配置此缓存管理器

    spring boot 使用jsp 集成hibernate+shiro+ehcache项目分享

    【Spring Boot 使用 JSP 集成 Hibernate+Shiro+Ehcache 项目详解】 Spring Boot 是一个基于 Spring 框架的高度集成了多种技术的开发工具,它简化了配置过程,使得开发人员能够快速构建可运行的应用程序。在这个项目...

    shiro缓存jar包

    在使用Shiro-Ehcache集成时,你需要在Shiro的配置文件(通常是`shiro.ini`)中指定Ehcache的配置。这包括定义缓存的名字、大小限制、过期策略等。例如: ``` [ehcache] cacheManagerConfigFile = classpath:...

    cas+shiro+ehcache+srping集成完整代码

    - 在Shiro配置中启用Ehcache作为缓存管理器,用于存储用户会话和权限信息。 5. **测试集成**: - 创建`castest.rar`中的测试应用,模拟多个受CAS保护的应用。 - 通过浏览器尝试访问这些应用,应该会在首次登录后...

    Shiro整合springboot报错代码

    在整合Apache Shiro框架与Spring Boot的过程中,可能会遇到各种错误,这些错误可能源自配置不当、依赖冲突或理解上的误区。本文将深入探讨Shiro与Spring Boot整合时可能出现的问题及其解决方案。 1. **Shiro的基本...

    SpringBoot中Shiro缓存使用Redis、Ehcache的方法

    主要介绍了SpringBoot中Shiro缓存使用Redis、Ehcache的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

Global site tag (gtag.js) - Google Analytics