记SpringBoot项目长时间未访问,出现页面找不到的问题

Posted hetangyuese

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记SpringBoot项目长时间未访问,出现页面找不到的问题相关的知识,希望对你有一定的参考价值。

最近某个开发环境的某个应用,隔三差五出现了某某页面找不到,网上百度找了些同类的问题都是说jstl包与默认tomcat里的包冲突,但都感觉和我的问题不是很搭配(因为相同框架的其他项目都可以正常允许)
  1. 报错信息如下:
    17:40:18.890 [http-nio-8088-exec-18] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.view.jsp.poi.detail_jsp] with root cause
    java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.view.jsp.xxx_jsp
            at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
            at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:129)
            at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:60)
            at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:128)
            at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:171)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:380)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:467)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:392)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
            at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)
            at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
            at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1286)
            at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1041)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:984)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  2. 原因
    说真的,起初一看到这样的问题,脑海里直接就闪出一个答案,服务器打的包有问题,但是隔三差五出现这样的问题,就开始怀疑真的是包问题?
    经验证并不是!!!!!!!!!!
    
    每当出现这样的问题,我都会重新打个包到线上,嗯,报错找不到的页面可以访问了,但是隔了和多天发现另外一个页面同样的问题;这个时候开始认真起来了,开始了百度寻找难兄难弟,一百度发现全是说的是包冲突;
    
    我检查了一遍包发现并没有那样的冲突,我猜是不是服务器的问题,我就重启了一下项目,这个时候之前报错的页面可以访问了。。。基本确定是和服务器有关!

    真正的原因

    有多少小伙伴知道springboot项目运行的项目解压文件在哪? 如果未自定义默认在/tmp文件夹下生成tomcat.xxxx文件,而linux有删除策略会删除临时文件
    项目编译文件地址

    技术图片

    为了保证tmp目录不爆满,linux服务器会自动删除一些长时间不访问的一些编译文件(具体怎么删不是很清楚),如果长达10天未访问的临时文件会被linux删除掉!!
    
    现在想想开发环境的这个项目经常很长时间没人访问,也没有自定义过编译文件目录,已经可以肯定就是这个问题导致的
  3. 解决方法

    在springboot的配置文件中增加配置,增加配置tomcat.basedir的路径
    
    server:
      port: 8088
      tomcat:
        basedir: /usr/local/tmp

    总结

    感谢道友!!!
    原文:https://www.liangzl.com/get-article-detail-133406.html
    切换了临时目录的小伙伴也需要时常去检查下新的目录下的编译文件的大小哦,及时删除!别过了很长时间导致撑爆了内存
    
    经常在项目中遇到各种各样的千奇百怪的问题, 怎么解决的、为什么还是要记录下来,因为你不知道啥时候又遇到了!!!

以上是关于记SpringBoot项目长时间未访问,出现页面找不到的问题的主要内容,如果未能解决你的问题,请参考以下文章

页面长时间未操作关闭页面重新登录

服务器 长时间未重启导致 反应迟缓

长时间未打开应用,收不到 GCM 推送通知

SpringBoot启动项目之后,访问页面出现Whitelabel Error Page

vue 用户长时间未操作退出登录

麒麟操作linux系统长时间未开机,然后就进不了系统了