JFinal开发项目,使用Ehcache做缓存,上线试运行期间每天都会有几次如下异常日志
JFinal开发项目,使用Ehcache做缓存,上线试运行期间每天都会有几次如下异常日志:
2014-05-27 11:30:59 [ERROR]-[Thread: HTTP-9081-exec-20]-[org.apache.shiro.web.servlet.AbstractShiroFilter.updateSessionLastAccessTime()]: session.touch() method invocation has failed. Unable to updatethe corresponding session's last access time based on the incoming request. org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000 at org.apache.shiro.cache.ehcache.EhCache.put(EhCache.java:105) at org.apache.shiro.session.mgt.eis.CachingSessionDAO.cache(CachingSessionDAO.java:247) at org.apache.shiro.session.mgt.eis.CachingSessionDAO.cache(CachingSessionDAO.java:235) at org.apache.shiro.session.mgt.eis.CachingSessionDAO.update(CachingSessionDAO.java:280) at org.apache.shiro.session.mgt.DefaultSessionManager.onChange(DefaultSessionManager.java:212) at org.apache.shiro.session.mgt.AbstractNativeSessionManager.touch(AbstractNativeSessionManager.java:193) at org.apache.shiro.session.mgt.DelegatingSession.touch(DelegatingSession.java:120) at org.apache.shiro.session.ProxiedSession.touch(ProxiedSession.java:100) at org.apache.shiro.web.servlet.AbstractShiroFilter.updateSessionLastAccessTime(AbstractShiroFilter.java:315) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:364) 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.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:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1721) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000 at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:939) at net.sf.ehcache.store.disk.Segment.decode(Segment.java:167) at net.sf.ehcache.store.disk.Segment.put(Segment.java:444) at net.sf.ehcache.store.disk.DiskStore.put(DiskStore.java:477) at net.sf.ehcache.store.FrontEndCacheTier.put(FrontEndCacheTier.java:257) at net.sf.ehcache.Cache.putInternal(Cache.java:1489) at net.sf.ehcache.Cache.put(Cache.java:1417) at net.sf.ehcache.Cache.put(Cache.java:1382) at org.apache.shiro.cache.ehcache.EhCache.put(EhCache.java:102) ... 30 more Caused by: java.io.StreamCorruptedException: invalid stream header: 00000000 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299) at net.sf.ehcache.util.PreferTCCLObjectInputStream.<init>(PreferTCCLObjectInputStream.java:39) at net.sf.ehcache.store.disk.DiskStorageFactory.read(DiskStorageFactory.java:375) at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:937) ... 38 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
访问速度快 感觉很明显
的确!
引用来自“枫林茵然”的评论
感谢@缪斯的情人的回答,终于找到问题的根源了,多个项目部署在同一个Tomcat下,diskStore没有修改造成的。
感谢@JFinal开源了这么好的框架,项目已上线试运行。网站地址:http://web.xf315.org/
感谢@缪斯的情人的回答,终于找到问题的根源了,多个项目部署在同一个Tomcat下,diskStore没有修改造成的。
感谢@JFinal开源了这么好的框架,项目已上线试运行。网站地址:http://web.xf315.org/
貌似被持久化的对象无法反序列化,看看是不是以前持久化的对象版本改变了,或是某些属性无法被正确反序列化
ehcache的原理是将所有的value值序列化后存储到本地磁盘,将一个与之对应的key值存到内存中,建立两者关联。这样就能根据key查找磁盘中的value了,当value值找不到时,或者序列化异常时就出现了你的问题。出现原因一般是这样子:value默认存储到tomcat临时目录tmp下(不同服务器不同系统该路径不同,参考 @红薯
http://www.oschina.net/question/12_2368),当tomcat下多个实例同时往这个目录下写入缓存时,就容易出现问题了。解决方案是指定下diskStore 目录为不同的目录。