gpt4 book ai didi

java - 从 Tomcat 7 迁移到 Tomcat 9 后的 "Too many open files"

转载 作者:太空狗 更新时间:2023-10-29 12:22:30 25 4
gpt4 key购买 nike

从 Tomact 7 迁移到 Tomcat 9.0.20(使用相同的 Java 版本 1.8.0_25 运行)后,我们在 Linux RHEL 7 上的 JSF2 Web 应用程序出现问题。一段时间后,我们得到如下异常:

java.io.FileNotFoundException: /f4m/tomcat/tomcat_f4mbs/webapps/ACM/WEB-INF/acm-config.xml (Too many open files)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)

经过一段时间的搜索,我发现有很多 xhtml 文件的打开文件描述符,通过执行以下命令(其中 4025 是 Tomcat 进程 ID):

ls -l /proc/4025/fd


lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 238 -> /usr/java/jdk1.8.0_25/jre/lib/resources.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 239 -> pipe:[3661823]
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 24 -> /f4m/tomcat/tomcat_f4mbscrm/lib/websocket-api.jar
l-wx------. 1 f4mHttp f4mHttp 64 May 16 09:01 240 -> pipe:[3661823]
lrwx------. 1 f4mHttp f4mHttp 64 May 16 09:01 241 -> anon_inode:[eventpoll]
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 243 -> pipe:[3661824]
l-wx------. 1 f4mHttp f4mHttp 64 May 16 09:01 244 -> pipe:[3661824]
lrwx------. 1 f4mHttp f4mHttp 64 May 16 09:01 245 -> anon_inode:[eventpoll]
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 246 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/msgBox.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 247 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/msgBox.xhtml
lrwx------. 1 f4mHttp f4mHttp 64 May 16 09:01 248 -> socket:[3667364]
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 249 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/searchpage.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 25 -> /f4m/tomcat/tomcat_f4mbscrm/lib/jasper.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 250 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/searchpage.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 251 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/portal/nav/portalheader.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 252 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/portal/customizing/nav/menu.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 253 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 254 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/nav/bottomPanel.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 255 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/nav/bottomPanel.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 256 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/msgBox.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:01 257 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 258 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 259 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 26 -> /f4m/tomcat/tomcat_f4mbscrm/lib/ecj-4.9.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 260 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 261 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 262 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/common/barcodefunction_incl.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 263 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/portal/nav/portalfooterAll.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 264 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartner.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 266 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartner.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 267 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/portal/nav/portalheader.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 268 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/portal/customizing/nav/menu.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 27 -> /f4m/tomcat/tomcat_f4mbscrm/lib/catalina-ha.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 274 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartner_topnav.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 275 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/msgBox.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 276 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/msgBox.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 277 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 278 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 279 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 28 -> /f4m/tomcat/tomcat_f4mbscrm/lib/jsp-api.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 280 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 281 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 282 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 283 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 286 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 287 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 288 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 289 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 29 -> /f4m/tomcat/tomcat_f4mbscrm/lib/annotations-api.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 290 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 291 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 292 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 293 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartnerparent_incl.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 294 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 295 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 296 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 297 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 298 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartnerHierarchySimilarAddresses.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 299 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartnerchild_incl.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 3 -> /usr/java/jdk1.8.0_25/jre/lib/rt.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 30 -> /f4m/tomcat/tomcat_f4mbscrm/lib/tomcat-i18n-fr.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 300 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 301 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 302 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 303 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 304 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/form/partner/crmpartnerHierarchySimilarAddresses.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 305 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 306 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 307 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 308 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 309 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 31 -> /f4m/tomcat/tomcat_f4mbscrm/lib/tomcat-coyote.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 310 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 311 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 312 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 313 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 314 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 315 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 316 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 317 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 318 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 319 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 08:58 32 -> /f4m/tomcat/tomcat_f4mbscrm/lib/catalina-ant.jar
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 320 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 321 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 322 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 323 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 324 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 325 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 326 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 327 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 328 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml
lr-x------. 1 f4mHttp f4mHttp 64 May 16 09:02 329 -> /f4m/tomcat/tomcat_f4mbscrm/webapps/ACM/resources/components/calendar.xhtml

这不是完整列表 - 还有更多。

列出的文件数量上下波动。对我来说,只要页面显示在浏览器中,xhtml(或其使用的组件之一)似乎就有一个打开的文件描述符。

如果我再次在 Tomcat 7 上部署相同的应用程序,我只能看到 JAR 文件、套接字的打开文件描述符,但永远看不到 xhtml 的打开文件描述符。

可能是什么问题?

最佳答案

文件泄漏发生在 JSF2 MyFaces 实现中,另请参见此处:https://marc.info/?l=myfaces-dev&m=152536956716792&w=2

我使用这个工具找到了问题:http://file-leak-detector.kohsuke.org/

关于java - 从 Tomcat 7 迁移到 Tomcat 9 后的 "Too many open files",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56165741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com