NutzCN Logo
问答 运行20天后,markdown的缓存, ehcache的disk抛异常了
发布于 3133天前 作者 wendal 5032 次浏览 复制 上一个帖子 下一个帖子
标签: ehcache

异常信息如下

```
2015-11-17 17:43:47,228 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:92) DEBUG - Found mapping for [GET] path=/yvr/t/pbcmansae2g5epbf8sh566164d : YvrModule.topic(...)
2015-11-17 17:43:47,229 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:145) DEBUG - Get 'yvrModule'<class net.wendal.nutzbook.module.yvr.YvrModule>
NATIVE_CALL_EXCEPTION
at org.beetl.core.statement.FunctionExpression.evaluate(FunctionExpression.java:85)
at org.beetl.core.statement.PlaceholderST.execute(PlaceholderST.java:32)
at org.beetl.core.statement.Program.execute(Program.java:70)
at org.beetl.core.Template.renderTo(Template.java:137)
at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:114)
at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.statement.ForStatement.execute(ForStatement.java:144)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.statement.IfStatement.execute(IfStatement.java:63)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.Tag.doBodyRender(Tag.java:60)
at org.beetl.core.Tag.getBodyContent(Tag.java:69)
at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:104)
at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
at org.beetl.core.statement.Program.execute(Program.java:70)
at org.beetl.core.Template.renderTo(Template.java:137)
at org.beetl.core.Template.renderTo(Template.java:103)
at org.beetl.ext.web.WebRender.render(WebRender.java:108)
at org.beetl.ext.nutz.BeetlView.render(BeetlView.java:28)
at net.wendal.nutzbook.beetl.BeetlViewMaker2$1.render(BeetlViewMaker2.java:61)
at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:55)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:51)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at net.wendal.nutzbook.mvc.LogTimeProcessor.process(LogTimeProcessor.java:19)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:183)
at net.wendal.nutzbook.mvc.NutzBookNutFilter.doFilter(NutzBookNutFilter.java:40)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
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.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
Caused by: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 65624669
at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:891)
at net.sf.ehcache.store.disk.Segment.decodeHit(Segment.java:182)
at net.sf.ehcache.store.disk.Segment.get(Segment.java:225)
at net.sf.ehcache.store.disk.DiskStore.fault(DiskStore.java:210)
at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:198)
at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:192)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.get(OnHeapCachingTier.java:334)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.access$200(OnHeapCachingTier.java:311)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier.get(OnHeapCachingTier.java:175)
at net.sf.ehcache.store.CacheStore.get(CacheStore.java:192)
at net.sf.ehcache.Cache.get(Cache.java:1751)
at net.sf.ehcache.Cache.get(Cache.java:1724)
at net.wendal.nutzbook.util.Markdowns.toHtml(Markdowns.java:76)
at net.wendal.nutzbook.beetl.MarkdownFunction.call(MarkdownFunction.java:13)
at org.beetl.core.statement.FunctionExpression.evaluate(FunctionExpression.java:76)
... 78 more
Caused by: java.io.StreamCorruptedException: invalid stream header: 65624669
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806)
at java.io.ObjectInputStream.(ObjectInputStream.java:299)
at net.sf.ehcache.util.PreferredLoaderObjectInputStream.(PreferredLoaderObjectInputStream.java:40)
at net.sf.ehcache.store.disk.DiskStorageFactory.read(DiskStorageFactory.java:368)
at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:887)
... 92 more
2015-11-17 17:43:47,239 org.beetl.ext.nutz.LogErrorHandler.processExcption(LogErrorHandler.java:32) DEBUG - 调用方法出错 markdown

05:43:47:调用方法抛出了异常(NATIVE_CALL_EXCEPTION):markdown 位于41行 资源:yvr/_reply.btl
调用方法出错 markdown
38| ${markdown(reply.content)}
39|
40|
41|
42|
43| <% if (null != obj.current_user!) { %>
========================
调用栈:
yvr/_reply.btl 行:41
yvr/_topic.btl 行:100
net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 65624669
at net.sf.ehcache.store.disk.DiskStorageFactory.retrieve(DiskStorageFactory.java:891)
at net.sf.ehcache.store.disk.Segment.decodeHit(Segment.java:182)
at net.sf.ehcache.store.disk.Segment.get(Segment.java:225)
at net.sf.ehcache.store.disk.DiskStore.fault(DiskStore.java:210)
at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:198)
at net.sf.ehcache.store.CacheStore$4.call(CacheStore.java:192)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.get(OnHeapCachingTier.java:334)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier$Fault.access$200(OnHeapCachingTier.java:311)
at net.sf.ehcache.store.cachingtier.OnHeapCachingTier.get(OnHeapCachingTier.java:175)
at net.sf.ehcache.store.CacheStore.get(CacheStore.java:192)
at net.sf.ehcache.Cache.get(Cache.java:1751)
at net.sf.ehcache.Cache.get(Cache.java:1724)
at net.wendal.nutzbook.util.Markdowns.toHtml(Markdowns.java:76)
at net.wendal.nutzbook.beetl.MarkdownFunction.call(MarkdownFunction.java:13)
at org.beetl.core.statement.FunctionExpression.evaluate(FunctionExpression.java:76)
at org.beetl.core.statement.PlaceholderST.execute(PlaceholderST.java:32)
at org.beetl.core.statement.Program.execute(Program.java:70)
at org.beetl.core.Template.renderTo(Template.java:137)
at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:114)
at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.statement.ForStatement.execute(ForStatement.java:144)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.statement.IfStatement.execute(IfStatement.java:63)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.Tag.doBodyRender(Tag.java:60)
at org.beetl.core.Tag.getBodyContent(Tag.java:69)
at org.beetl.ext.tag.LayoutTag.render(LayoutTag.java:104)
at org.beetl.core.statement.TagStatement.runTag(TagStatement.java:108)
at org.beetl.core.statement.TagStatement.execute(TagStatement.java:87)
at org.beetl.core.statement.Program.execute(Program.java:70)
at org.beetl.core.Template.renderTo(Template.java:137)
at org.beetl.core.Template.renderTo(Template.java:103)
at org.beetl.ext.web.WebRender.render(WebRender.java:108)
at org.beetl.ext.nutz.BeetlView.render(BeetlView.java:28)
at net.wendal.nutzbook.beetl.BeetlViewMaker2$1.render(BeetlViewMaker2.java:61)
at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:55)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:40)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:51)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:113)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at net.wendal.nutzbook.mvc.LogTimeProcessor.process(LogTimeProcessor.java:19)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:40)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:183)
at net.wendal.nutzbook.mvc.NutzBookNutFilter.doFilter(NutzBookNutFilter.java:40)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
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.do

5 回复

原因是, 我部署了一个新站, 而这个站的ehcache.xml没有改,导致里面的存储路径与nutz.cn一样,结果就出事了

这事早上就有征兆, 就是另外一个站的session总是不能保存, 重启浏览器就丢, 当时也没想到是cache文件夹冲突了

查原因, DiskStoreConfiguration.translatePath方法,负责把ehcache.xml中的路径进行变量替换

    private static String translatePath(String path) {
        String translatedPath = substituteProperties(path);
        for (Env e : Env.values()) {
            translatedPath = e.substitute(translatedPath);
        }
        // Remove duplicate separators: Windows and Solaris
        translatedPath = translatedPath.replace(File.separator + File.separator, File.separator);
        LOG.debug("Disk Store Path: " + translatedPath);
        return translatedPath;
    }

那支持哪些变量呢? 只有4个, 而且存在才替换,不存在就不替换, 坑

    private static enum Env {
        USER_HOME("user.home"),
        USER_DIR("user.dir"),
        JAVA_IO_TMPDIR("java.io.tmpdir"),
        EHCACHE_DISK_STORE_DIR("ehcache.disk.store.dir");

        private final String variable;

        Env(String variable) {
            this.variable = variable;
        }

        String substitute(String string) {
            String substitution = System.getProperty(variable);
            if (substitution == null) {
                return string;
            } else {
                return string.replaceFirst(Pattern.quote(variable), Matcher.quoteReplacement(substitution));
            }
        }
    }

最好还是得删除ehcache的全部缓存文件, 恢复老的备份...

添加回复
请先登陆
回到顶部