我有一个在 Tomcat 9 上运行的 Java-web 应用程序。它在 Windowns 机器上运行良好。但是在 Debian Linux 服务器上部署此应用程序后,我在某些特定页面上遇到了 java.lang.StackOverflow 异常。这是堆栈跟踪日志的开头:
27-Dec-2017 08:54:43.746 SEVERE [https-jsse-nio-9443-exec-3]
org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for
servlet [jsp] threw exception
java.lang.StackOverflowError
at java.io.UnixFileSystem.canonicalize0(Native Method)
at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:172)
at java.io.File.getCanonicalPath(File.java:618)
at org.apache.catalina.webresources.AbstractFileResourceSet.file(AbstractFileResourceSet.java:90)
请在此处查看完整的堆栈跟踪: https://pastebin.com/0AmFDY8F
据我了解,Jasper 编译JSP 页面源代码时出现异常,这与Linux 路径/目录的解析有某种关系。谁能帮我弄清楚到底是什么问题?如果问题可能与此相关,我没有创建任何符号链接(symbolic link)。
最佳答案
根据您的堆栈跟踪,问题是由于无法找到由您的 Spring 框架解析的特定路径引起的:
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
...
Caused by: java.io.IOException: JSPException including path '/struct/context/tutorials.jsp'.
Spring 框架很可能使用规范路径来解析文件,但失败可能是因为框架中存在一些与您要部署到的 Unix 系统类型相关的怪癖。
请在 Spring 文档中引用它:
The default script supports most Linux distributions and is tested on CentOS and Ubuntu. Other platforms, such as OS X and FreeBSD, will require the use of a custom embeddedLaunchScript.
请注意,Debian 未列出。希望这能让您走上正确的道路。
如果我在这里追逐一条红鲱鱼,我很抱歉 - 但你没有给我们太多继续下去的机会。
关于Java webapp 在 Linux 上产生 StackOverflow 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47994103/