JBoss太多文件打开错误

时间:2009-10-15 13:46:38

标签: jboss

就在上周,我遇到了访问JBoss(v 4.2.2)Web应用程序的问题。当我转到主页时,我得到一个java.lang.NullPointerException错误页面。在查看JBoss日志输出后,似乎打开了太多文件,那么我将如何关闭这些文件呢?以下是JBoss日志的输出:

  ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    java.io.FileNotFoundException: /usr/local/jboss-4.2.2.GA/server/default/work/jboss.web/localhost/catissuecore/org/apache/jsp/pages/content/home/Error_jsp.java (Too many open files)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:152)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:316)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:447)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:423)
    at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:270)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:619)
    ERROR [[localhost]] Exception Processing ErrorPage[exceptionType=java.lang.Exception, location=/pages/content/home/Error.jsp]
    org.apache.jasper.JasperException: Unable to compile class for JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:574)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:316)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:447)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:423)
    at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:270)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.FileNotFoundException: /usr/local/jboss-4.2.2.GA/server/default/work/jboss.web/localhost/catissuecore/org/apache/jsp/pages/content/home/Error_jsp.java (Too many open files)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
    at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:152)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
    ... 21 more

3 个答案:

答案 0 :(得分:12)

首先,您要确定哪些文件保持打开状态。我假设你的服务器运行linux,所以一旦你知道JBoss'es PID

ps ax | grep something-that-makes-your-jboss-process-unique

你可以做到

ls -l /proc/jbosspid/fd

获取一个在该时刻打开的文件列表。

接下来你要做什么取决于你在这里看到的内容:

  1. 您可能只需要增加服务器可以使用ulimit打开的文件数量(同时查看服务器上的系统范围限制)
  2. 也许您发现了应用程序忘记关闭的大量文件
  3. ....
  4. 但要关闭这些文件/摆脱打开的文件,你必须重新启动JBoss实例。

答案 1 :(得分:6)

假设您在linux(或其他* NIX)上运行,那么每个进程的文件描述符限制为1024。在Unix中,一切都是文件 - 包括套接字,设备等。看看这个的wat是运行lsof命令(仅作为root) - 它将显示所有打开的文件描述符。

为了解决这个问题,请在/etc/security/limits.conf中编辑文件并添加以下行并重新启动jboss。

jboss          soft    nofile          16384
jboss          hard    nofile          16384

(假设您的jboss由“jboss”用户运行)

答案 2 :(得分:3)

我也有这个问题(在linux上)。 我做了什么:

  1. 检查限制:ulimit -a
  2. 检查输出中的2行:
  3.     open files                      (-n) 1024
        max user processes              (-u) 1024
    
    1. 设置两个参数(例如在.bash_profile中)
    2.     ulimit -n 100000
          ulimit -u 100000
      

      在我的情况下,我必须更改两个参数才能解决问题。