2009-10-15 97 views
6

就在上個星期,我一直在訪問JBoss(v 4.2.2)Web應用程序的問題。當我進入主頁時,我得到一個java.lang.NullPointerException錯誤頁面。查看JBoss日誌輸出後,看起來有太多文件已打開,那麼我將如何去關閉這些文件?下面是來自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 

回答

11

首先要確定哪些文件(S)保持開放。我假設你的服務器運行Linux操作系統,所以一旦你知道JBoss'es PID

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

你可以做

ls -l /proc/jbosspid/fd 

讓那些在那一時刻打開文件的一個很好的列表。

什麼你下一步準備做取決於你在這裏看到的一點:

  1. 你可能只需要的文件數量的服務器可以打開有點用ulimit(也期待在全系統您的服務器上限值)
  2. 也許你發現了一些文件的應用程序忘了關
  3. ....

但要關閉這些文件/幹掉你要打開的文件的重啓JBos這個例子。

+4

+1用於在增加ulimit之前檢查泄漏。 – 2009-10-15 21:45:17

5

假設你在linux(或其他* NIX)上運行,那麼每個進程的文件描述符限制爲1024。在Unix中,一切都是一個文件 - 包括套接字,設備等等。有一個看看這個的wat是運行lsof命令(僅作爲root用戶) - 它會顯示所有打開的文件描述符。

爲了解決這個問題,請編輯/etc/security/limits.conf中的文件並添加以下行並重新啓動您的jboss。

jboss   soft nofile   16384 
jboss   hard nofile   16384 

(假設你的JBoss是由 「JBoss的」 用戶身份運行)

3

我有這個問題還(在Linux上)。 我所做的:

  1. 檢查範圍:-a的ulimit
  2. 檢查2線輸出:
 
    open files      (-n) 1024 
    max user processes    (-u) 1024 
  1. (在你的.bash_profile爲例)設置兩個參數
 
    ulimit -n 100000 
    ulimit -u 100000 

在我的情況下,我不得不改變這兩個參數來解決問題。

相關問題