配置shiro ehcache 出现这个异常,(未解决) java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager

参考 https://www.cnblogs.com/zfding/p/8536480.html

Caused by: org.springframework.beans.FatalBeanException: Error initializing bean [cacheManager]; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager
at org.apache.shiro.spring.LifecycleBeanPostProcessor.postProcessBeforeInitialization(LifecycleBeanPostProcessor.java:91)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 44 more
Caused by: org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager
at org.apache.shiro.cache.ehcache.EhCacheManager.ensureCacheManager(EhCacheManager.java:223)
at org.apache.shiro.cache.ehcache.EhCacheManager.init(EhCacheManager.java:198)
at org.apache.shiro.spring.LifecycleBeanPostProcessor.postProcessBeforeInitialization(LifecycleBeanPostProcessor.java:89)
... 47 more
Caused by: net.sf.ehcache.CacheException: java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager
at net.sf.ehcache.CacheManager.init(CacheManager.java:415)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:352)
at org.apache.shiro.cache.ehcache.EhCacheManager.ensureCacheManager(EhCacheManager.java:212)
... 49 more
Caused by: java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager
at net.sf.ehcache.statistics.StatisticBuilder$OperationStatisticBuilder.build(StatisticBuilder.java:79)
at net.sf.ehcache.Cache.<init>(Cache.java:260)
at net.sf.ehcache.config.ConfigurationHelper.createCache(ConfigurationHelper.java:296)
at net.sf.ehcache.config.ConfigurationHelper.createDefaultCache(ConfigurationHelper.java:219)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:754)
at net.sf.ehcache.CacheManager.doInit(CacheManager.java:455)
at net.sf.ehcache.CacheManager.init(CacheManager.java:392)
... 51 more
Caused by: java.lang.ClassNotFoundException: org.terracotta.statistics.StatisticsManager
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1945)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1788)
... 58 more

导入ehcache-3、ehcache-2 jar 的都不行,shiro.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:cache="http://www.springframework.org/schema/cache"
       xsi:schemaLocation=
       "http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/cache
        http://www.springframework.org/schema/cache/spring-cache.xsd">
    <!-- Shiro主过滤器本身功能十分强大,它支持任何基于URL路径表达式的、自定义的过滤器 -->
     <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean" >
         <property name="securityManager" ref="securityManager"/>
         <!-- 当访问需要认证的资源时,如果没有认证,将自动跳到该url
             如果不配置该属性,默认为根目录下的login.jsp         -->
         <property name="loginUrl" value="/login.jsp"></property>
         <!-- 配置成功后跳转到哪个url上,通常不设置,默认认证成功后跳转上上一个url -->
        <property name="successUrl" value="/main.jsp" ></property>
         <!-- 没有权限访问资源时跳转的页面 -->
         <property name="unauthorizedUrl" value="refuse"></property>
         <!-- shiro的过滤器链  具体配置需要拦截哪些URL,以及访问对应的URL时
         使用Shiro的默认Filter进行拦截-->
         <property name="filterChainDefinitions">
        <!--anon  任何人都可以访问
            authc 必须是登录之后才能访问,不包括remember me
            user  登录用户才可以访问
            perms 指定过滤规则,扩展使用
        -->
             <value>
                 /toLogin=anon
                 /login-s=anon
                 /logout=logout
                 /main=user
                 /**=anon
             </value>
         </property>
     </bean>
     <!-- authc过滤器 -->
     <bean id="authc" class="org.apache.shiro.web.filter.authc.FormAuthenticationFilter">
         <property name="usernameParam" value="uname"></property>
         <property name="passwordParam" value="pwd" ></property>
         <property name="rememberMeParam" value="rememberMe"></property>
     </bean>
     <!-- logout过滤器 -->
     <bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter">
         <property name="redirectUrl" value="/toLogin"></property>
     </bean>
     <!-- 缓存管理器 -->
     <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
         <property name="cacheManagerConfigFile" value="classpath:ehcache-shiro.xml"></property>
     </bean>
     <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
         <!-- 若有多个Realm,可使用realms 代替 -->
         <property name="realm" ref="userRealm"></property>
         <property name="cacheManager" ref="cacheManager"></property>
         <property name="sessionManager" ref="sessionManager"></property>
         <property name="rememberMeManager" ref="rememberMeManager"></property>
     </bean>
     <bean id="userRealm" class="com.bjsxt.realm.UserRealm">
         <property name="credentialsMatcher" ref="credentialsMatcher" ></property>
     </bean>
     <!-- 会话管理器 -->
     <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
         <property name="globalSessionTimeout" value="300000"></property>
         <!-- 删除无效session -->
         <property name="deleteInvalidSessions" value="true"></property>
     </bean>
     <!-- 记住我配置 -->
     <bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
         <property name="cookie" ref="rememberMeCookie"></property>
     </bean>
     <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie ">
         <property name="maxAge" value="604800" />
         <!-- 设置cookie的名称 -->
         <property name="name" value="rememberMe"></property>
     </bean>
     <!-- 必须配置lifecycleBeanPostProcessor:管理shiro中常见的对象 -->
     <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" ></bean>
     <bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
         <property name="hashAlgorithmName" value="md5"></property>
         <property name="hashIterations" value="10"></property>
     </bean>

 </beans>
        

shiro.xml换了shiro自带的缓存

 <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager">

就可以正常启动了。

原文地址:https://www.cnblogs.com/snhk/p/10801179.html

时间: 2024-10-10 18:54:24

配置shiro ehcache 出现这个异常,(未解决) java.lang.NoClassDefFoundError: org/terracotta/statistics/StatisticsManager的相关文章

【eclipse】 怎么解决java.lang.NoClassDefFoundError错误

前言 在日常Java开 发中,我们经常碰到java.lang.NoClassDefFoundError这样的错误,需要花费很多时间去找错误的原因,具体是哪个类不见了?类 明明还在,为什么找不到?而且我们很容易把java.lang.NoClassDefFoundError和 java.lang.ClassNotfoundException这两个错误搞混,事实上这两个错误是完全不同的.我们往往花费时间去不断尝试一些其他 的方法去解决这个问题,而没有真正去理解这个错误的原因.这篇文章就是通过解决NoC

怎么解决java.lang.NoClassDefFoundError错误

前言 在日常Java开发中,我们经常碰到java.lang.NoClassDefFoundError这样的错误,需要花费很多时间去找错误的原因,具体是哪个类不见了?类明明还在,为什么找不到?而且我们很容易把java.lang.NoClassDefFoundError和java.lang.ClassNotfoundException这两个错误搞混,事实上这两个错误是完全不同的.我们往往花费时间去不断尝试一些其他的方法去解决这个问题,而没有真正去理解这个错误的原因.这篇文章就是通过解决NoClass

关于怎么解决java.lang.NoClassDefFoundError错误

五一在部署新的统一登录时,遇到这样一个问题: 很容易把java.lang.NoClassDefFoundError和java.lang.ClassNotfoundException这两个错误搞混,事实上这两个错误是完全不同的. NoClassDefFoundError错误发生的原因 NoClassDefFoundError错误的发生,是因为Java虚拟机在编译时能找到合适的类,而在运行时不能找到合适的类导致的错误.例如在运行时我们想调用某个类的方法或者访问这个类的静态成员的时候,发现这个类不可用

解决 java/lang/NoClassDefFoundError: java/lang/Object 错误

安装完JDK ,设定环境变量后出现这个错误: [[email protected] lib]# javacError occurred during initialization of VMjava/lang/NoClassDefFoundError: java/lang/Object [[email protected] lib]# javaError occurred during initialization of VMjava/lang/NoClassDefFoundError: jav

类找不到异常 Caused by: java.lang.NoClassDefFoundError

错误原因:在部署应用的时候,服务器报错,Caused by: java.lang.ClassNotFoundException: org.quartz.impl.JobDetailImpl,某个类找不到,找到对应的包发现明明某个jar已经引进去了,在仔细一看发现有三个类似的jar, com.alibaba.external:opensymphony.quartz,opensymphony:quartz,org.quartz-scheduler:quartz.实际上我希望的包,是org.quart

解决java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/Pattern

明明引入了这个,却提示没有 看下面文章: http://lib.csdn.net/article/computernetworks/16110 (3)我按照网上的方法更换了logback jar包的版本,由1.0.9改成了1.0.11,问题并没有解决,又尝试了几个版本,依旧无解:其实在想到是jar包冲突的时候,我尝试着用exclusion不引入第三方的logback依赖,如下: <exclusion> <groupId>ch.qos.logback</groupId>

解决java.lang.NoClassDefFoundError: org/apache/log4j/Level

现象: java.lang.NoClassDefFoundError: org/apache/log4j/Level at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112

解决java.lang.NoClassDefFoundError错误

唉!tomcat 启动了一下午,一直出现这个问题   java.lang.NoClassDefFoundError ,遇到了这么问题,是由于jar包冲突引起的 是因为运行的时候需要用的jar包版本不对 虽然我的不是maven项目,,也是受了这个人的启发 https://www.cnblogs.com/wangzun/p/7530541.html,,,感谢啊 原文地址:https://www.cnblogs.com/dreamHighMjc/p/8605893.html

【COCOS2D-X 备注篇】ASSETMANAGEREX使用异常解决备注-&gt;CHECK_JNI/CC‘JAVA.LANG.NOCLASSDEFFOUNDERROR’

本站文章均为李华明Himi原创,转载务必在明显处注明:(作者新浪微博:@李华明Himi) 转载自[黑米GameDev街区] 原文链接: check_jni.cc JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception 'java.lang.NoClassDefFoundError' thrown in unknown throw location>http://www.himigame.c