jiangboqj
jiangboqj
采纳率100%
2017-07-06 05:43 阅读 7.0k
已采纳

项目在tomcat运行几天以后会ehcache错误,重启以后又可以正常运行,具体错误信息如下:

100

2017-07-05 09:56:56,466 [ajp-bio-8021-exec-10] ERROR [500.jsp] - net.sf.ehcache.CacheException: java.io.OptionalDataException
org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.io.OptionalDataException
at org.apache.shiro.cache.ehcache.EhCache.get(EhCache.java:85)
at org.apache.shiro.realm.AuthorizingRealm.getAuthorizationInfo(AuthorizingRealm.java:328)
at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:461)
at org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:457)
at org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
at org.apache.shiro.authz.ModularRealmAuthorizer.checkPermission(ModularRealmAuthorizer.java:322)
at org.apache.shiro.mgt.AuthorizingSecurityManager.checkPermission(AuthorizingSecurityManager.java:137)
at org.apache.shiro.subject.support.DelegatingSubject.checkPermission(DelegatingSubject.java:205)
at org.apache.shiro.authz.aop.PermissionAnnotationHandler.assertAuthorized(PermissionAnnotationHandler.java:74)
at org.apache.shiro.authz.aop.AuthorizingAnnotationMethodInterceptor.assertAuthorized(AuthorizingAnnotationMethodInterceptor.java:84)
at org.apache.shiro.authz.aop.AnnotationsAuthorizingMethodInterceptor.assertAuthorized(AnnotationsAuthorizingMethodInterceptor.java:100)
at org.apache.shiro.authz.aop.AuthorizingMethodInterceptor.invoke(AuthorizingMethodInterceptor.java:38)
at org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor.invoke(AopAllianceAnnotationsAuthorizingMethodInterceptor.java:115)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.oc.modules.fb.web.InfoController$$EnhancerBySpringCGLIB$$1cc7bd3.list()
at sun.reflect.GeneratedMethodAccessor918.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: net.sf.ehcache.CacheException: java.io.OptionalDataException
at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:914)
at net.sf.ehcache.store.disk.Segment.decodeHit(Segment.java:183)
at net.sf.ehcache.store.disk.Segment.get(Segment.java:221)
at net.sf.ehcache.store.disk.DiskStore.get(DiskStore.java:467)
at net.sf.ehcache.store.FrontEndCacheTier.get(FrontEndCacheTier.java:201)
at net.sf.ehcache.Cache.searchInStoreWithoutStats(Cache.java:2070)
at net.sf.ehcache.Cache.get(Cache.java:1590)
at org.apache.shiro.cache.ehcache.EhCache.get(EhCache.java:73)
... 79 more

看哪位大神遇到过此类问题,麻烦不吝赐教,在此先谢过。
(备注:我没有在同一个tomcat下部署多个项目,ehcache存储的目录位tomcat下的temp目录)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • 已采纳
    jiangbolh jiangbolh 2018-03-09 01:25

    我更新一下最后的解决方案吧,经过详细测试发现,项目配置的是ehcache缓存,然后在标签中overflowToDisk=true,
    每当内存中达到最高配置的缓存数时,就会往磁盘里写入缓存对象,这个时候就会报这个错。但是当在我本机上测试是没有这个错的,
    只有把项目部署到阿里云服务器上才会出现这个问题。我本机是windows,服务器是linux,可能是由于磁盘格式不一样导致的,我没有继续查了。
    只是最后修改了overflowToDisk=false就再也没出现这个问题了

    点赞 评论 复制链接分享
  • zhang929084299 zhang929084299 2017-07-06 15:14

    net.sf.ehcache.CacheException: java.io.OptionalDataException
    这个是缓存的异常,异常原因是IO流的写入问题,对于这个异常,我没有在tomcat遇到过,
    刚百度了下 http://blog.csdn.net/Giving_bestself/article/details/51919516
    这篇文章写了在java中遇到怎么办,让我想起一种可能,缓存的写入出错,也就是说可能
    ①内存不足,导致写入和读出时让有的字符写了一半或者读了一半,
    ②缓存溢出,几天后写入的缓存日志溢出。
    个人建议写个缓存清理的代码块,每隔一段时间清理缓存,或者去配置文件设置成自动清理。
    以上纯属个人猜测。。。

    点赞 评论 复制链接分享
  • jiangboqj jiangboqj 2017-07-10 05:51

    奇怪的是,报了这个错以后,同一个用户在我电脑上登陆会报错,其他电脑登陆正常,如果是你所说的①②原因,那应该同一个用户登陆都用报这个错的。不管怎么样,谢谢你的回答,非常感谢,这个问题我还得继续查了。

    点赞 评论 复制链接分享
  • jiangboqj jiangboqj 2017-07-24 09:03

    没有人遇到过同类型的错误,求解答!

    点赞 评论 复制链接分享
  • jiangboqj jiangboqj 2017-09-07 01:18

    怎么没人回答了,有高人没?

    点赞 评论 复制链接分享

相关推荐