2013-01-14 60 views
1

我正在做一個線程在DB中創建一些插入,而Ajax方法每隔0.5s向該線程發送請求以檢查該過程。 過了一段時間,我得到了卡塔林納輸出中的下一個異常,並且線程死亡。線程錯誤(jdom.jar(太多打開的文件))

任何人都可以解釋我做錯了什麼?

我使用tomcat 7和struts 2.0。

java.lang.reflect.InvocationTargetException 
at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:616) 
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:274) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.array(JSONWriter.java:509) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:143) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:383) 
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:275) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:383) 
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:275) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.map(JSONWriter.java:430) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:140) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.add(JSONWriter.java:383) 
at com.googlecode.jsonplugin.JSONWriter.bean(JSONWriter.java:275) 
at com.googlecode.jsonplugin.JSONWriter.process(JSONWriter.java:161) 
at com.googlecode.jsonplugin.JSONWriter.value(JSONWriter.java:115) 
at com.googlecode.jsonplugin.JSONWriter.write(JSONWriter.java:82) 
at com.googlecode.jsonplugin.JSONUtil.serialize(JSONUtil.java:98) 
at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:179) 
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:362) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266) 
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) 
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) 
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at com.humanlike.web.interceptors.LoginInterceptor.intercept(LoginInterceptor.java:57) 
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) 
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) 
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468) 
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:636) 

Caused by: java.io.FileNotFoundException: /usr/local/tomcat_demo/apache-tomcat-7.0.22/webapps/demo2/WEB-INF/lib/jdom.jar (Too many open files) 
at java.io.FileInputStream.open(Native Method) 
at java.io.FileInputStream.<init>(FileInputStream.java:137) 
at java.io.FileInputStream.<init>(FileInputStream.java:96) 
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:87) 
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:178) 
at java.net.URLConnection.getContent(URLConnection.java:705) 
at java.net.URL.getContent(URL.java:1043) 
... 92 more 
+0

標題似乎暗示你打開了太多的文件,你是否關閉了你已經完成的文件? –

+0

你正在使用什麼操作系統? – 2013-01-14 16:27:40

+0

@JonTaylor我不打開任何文件,這個錯誤似乎是從外部庫。 – Kongol

回答

0

在linux中有多少文件可以打開任何進程是有限制的。在Linux中的文件比在Windows中更寬(除了普通文件,還有套接字,管道......)。在你的代碼中的某處,你打開了太多的文件,或者可能是套接字。所以試着找出你有資源泄漏的地方。

+0

我知道,但即時通訊不處理文件,但它可能是一個與log4j的問題? – Kongol

1

您正在使用Struts 2並通過Ajax從客戶端發送請求。檢查是否真的需要爲每個請求創建單獨的線程。

Struts 2爲每個新請求創建一個新的Action對象。所以我認爲你不需要創建線程。