今天早些时候,我访问了我最近推出的一个网站,页面上充斥着一个丑陋的jasperex0019:java.io.filenotfoundexception: /opt/tomcat/webapps/root/web-inf/lib/jstl-1.2.jar(打开的文件太多)。我检查了我的服务器日志和tomcat日志,它们充满了相同的错误。我增加了tomcat的最大打开文件限制,作为保持网站运行的临时解决方案,但它很快又被填满了。我已经用同样的方法推出了其他网站,以前从未有过这个问题。这次我做的唯一不同的事情是使用Mobirise为前端做基本布局,所以我不排除Mobirise使用的一些脚本可能是罪魁祸首。但是当我看到tomcat打开的文件列表时,我看到它打开了数百个tomcat-users.xml副本,而且它越来越多地打开。
...
java 319 tomcat 935r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 936r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 937r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 938r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 939r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 940r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 941r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 942r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 943r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 944r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 945r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 946r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 947r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 948r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 949r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 950r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 951r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 952r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 953r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 954r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 955r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 956r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 957r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 958r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 959r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 960r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 961r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 962r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 963r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
java 319 tomcat 964r REG 253,1 2164 263714 /opt/tomcat/conf/tomcat-users.xml
...
我不明白它为什么这么做。我一直在调试、扫描代码,并在互联网上搜寻tomcat不断打开过多文件的问题,但他们都说“增加最大文件限制”它们都没有解决问题的根源,也没有提到关于tomcat的任何内容,只是无限地打开单个文件的副本。
[编辑]:以下是FileNotFoundException的完整堆栈跟踪:
28-Nov-2018 03:51:33.857 SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception
java.io.FileNotFoundException: /opt/tomcat/webapps/ROOT/WEB-INF/lib/jstl-1.2.jar (Too many open files)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:164)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.descriptor.tld.TldResourcePath.openJar(TldResourcePath.java:134)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:125)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1445)
at org.apache.jasper.compiler.Parser.parse(Parser.java:144)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:105)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:206)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:385)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
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:53)
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:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at kom.kitten.gingerpage.servlets.HomeServlet.doGet(HomeServlet.java:16)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
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:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
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.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
28-Nov-2018 03:51:33.859 SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [kom.kitten.gingerpage.servlets.HomeServlet] in conte$
java.io.FileNotFoundException: /opt/tomcat/webapps/ROOT/WEB-INF/lib/jstl-1.2.jar (Too many open files)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:164)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.descriptor.tld.TldResourcePath.openJar(TldResourcePath.java:134)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:125)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1445)
at org.apache.jasper.compiler.Parser.parse(Parser.java:144)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:244)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:105)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:206)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:385)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:400)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
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:53)
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:712)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:384)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at kom.kitten.gingerpage.servlets.HomeServlet.doGet(HomeServlet.java:16)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
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:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
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.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
这与每次发生错误时记录的堆栈跟踪相同(即,当tomcat中打开的文件太多时,每次有人试图在站点上加载页面时)
如果在Tomcat上部署了应用程序。首先,您必须确保在打开文件时显式地关闭它。您可以使用以下命令查看linux中打开的文件:
lsof -p <process Id of Tomcat>
在将应用程序从tomcat7实例移动到Tomcat9实例之后,我遇到了同样的问题。我觉得这可能是一只雄猫虫。我取下了标签
<Resource pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
type="org.apache.catalina.UserDatabase"
auth="Container" name="UserDatabase"/>
在$CATALINA_HOME/conf/server中的GlobalNamingResources标记中。重新启动后,问题自行解决。所以我猜问题在于Tomcat的管理应用程序。
这是由Tomcat 9.0.13中的一个错误引起的,该错误已在Tomcat 9.0.14中修复。
我有一个在tomcat上运行的应用程序,有时会出现以下错误: .... 我检查了打开文件的限制,它是1024个,但是当我检查了lsof应用程序的打开文件数量时,它接近200个,如果它没有达到限制,为什么会发生这种情况?我应该增加限额吗?是否有其他原因导致此错误?让服务重新正常运行的唯一方法是重新启动tomcat,还有其他恢复正常的方法吗? 提前谢谢。 编辑:这里是处理doPost方法的servle
我想知道太多文件打开错误的确切问题。我通过谷歌寻找解决方案,但我不知道为什么会出现这个问题以及如何解决这个问题。 堆栈错误:严重:套接字接受失败。网SocketException:java上打开的文件太多。网普通袜子。java上的socketAccept(本机方法)。网抽象素socketimpl。在java上接受(AbstractPlainSocketImpl.java:398)。网服务器插座。j
我们正在AmazonLinux中的ApacheTomcat中运行一个web服务。最初web服务运行正常。在发出1000多个web请求后,我们收到了太多的打开文件异常。当我们重新启动tomcat服务器时,这个问题将再次得到解决。 请查看以下例外情况 附言:我们在网络服务中没有做任何与文件相关的操作。
从Tomcat 7迁移到Tomcat 9.0之后。20(使用相同的Java版本1.8.0_25运行)我们在Linux RHEL 7上的JSF2 web应用程序存在问题。一段时间后,我们会遇到如下异常: 经过一段时间的搜索,我发现xhtml文件有许多打开的文件描述符,通过执行这个命令(其中4025是Tomcat进程ID): 这不是完整的列表-还有很多。 列出的文件数量会上下波动。对我来说,只要页面在
问题内容: 我使用多个文件来执行一些文件I / O(写入19个文件,确实如此)。写他们几百次后,我得到了。但实际上我一次只能打开几个文件。这里有什么问题?我可以验证写入是否成功。 问题答案: 在Linux和其他UNIX /类似UNIX的平台上,操作系统对进程在任何给定时间可能具有的打开文件描述符的数量进行了限制。在过去,此限制曾经是硬接线1,并且相对较小。如今,它要大得多(几百/千),并且受“软”
问题内容: 我写了一种测试套件,它占用大量文件。一段时间(2h)之后,我得到了。我仔细检查了所有文件句柄是否再次关闭它们。但是错误仍然存在。 我试图找出使用允许的文件描述符的数量以及当前打开的文件描述符的数量: 因此,如果我运行以下测试: 我得到以下输出: 真奇怪,我期望打开的文件描述符会越来越多。我的脚本正确吗? 我正在使用python的记录器和子进程。那可能是我FD泄漏的原因吗? 谢谢,丹