본문 바로가기
IT 지식정리/Troubleshoot

java.io.IOException: Too many open files 에러

by G. Hong 2018. 12. 8.
728x90
반응형

아래와 같은 에러메세지들이 지속적으로 발생 할 때, 시도 해 볼 수 있는 방법입니다.



2018-09-20 04:06:01,309 [ clientInboundChannel-190353] ERROR DataAccess|Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null

2018-09-20 04:06:01,309 [ clientInboundChannel-190353] WARN DataAccess|Failed to retrieve data

java.util.concurrent.CompletionException: org.apache.mina.core.RuntimeIoException: Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null

at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)

at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)

at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)

at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:614)

at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:1983)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultInvestigateRepository.findLanguages(DefaultInvestigateRepository.java:165)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultInvestigateRepository$$FastClassBySpringCGLIB$$6ff03bc6.invoke()

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultInvestigateRepository$$EnhancerBySpringCGLIB$$66a6ccb.findLanguages()

at com.rsa.asoc.nw.investigate.server.service.DefaultInvestigateService.findLanguages(DefaultInvestigateService.java:85)

at com.rsa.asoc.nw.investigate.server.service.DefaultInvestigateService.findAliases(DefaultInvestigateService.java:121)

at com.rsa.asoc.nw.web.common.service.DefaultWebSocketMessagingService.message(DefaultWebSocketMessagingService.java:96)

at com.rsa.asoc.nw.investigate.server.web.socket.InvestigateController.findAliases(InvestigateController.java:122)

at com.rsa.asoc.nw.investigate.server.web.socket.InvestigateController$$FastClassBySpringCGLIB$$73853dbe.invoke()

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:69)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)

at com.rsa.asoc.nw.investigate.server.web.socket.InvestigateController$$EnhancerBySpringCGLIB$$d8cd6791.findAliases()

at sun.reflect.GeneratedMethodAccessor313.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:180)

at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:112)

at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMatch(AbstractMethodMessageHandler.java:504)

at org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.handleMatch(SimpAnnotationMethodMessageHandler.java:497)

at org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.handleMatch(SimpAnnotationMethodMessageHandler.java:87)

at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessageInternal(AbstractMethodMessageHandler.java:463)

at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessage(AbstractMethodMessageHandler.java:401)

at org.springframework.messaging.support.ExecutorSubscribableChannel$SendTask.run(ExecutorSubscribableChannel.java:135)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Caused by: org.apache.mina.core.RuntimeIoException: Failed to create a new instance of org.apache.mina.transport.socket.nio.NioProcessor:null

at org.apache.mina.core.service.SimpleIoProcessorPool.(SimpleIoProcessorPool.java:220)

at org.apache.mina.core.service.SimpleIoProcessorPool.(SimpleIoProcessorPool.java:115)

at org.apache.mina.core.polling.AbstractPollingIoConnector.(AbstractPollingIoConnector.java:97)

at org.apache.mina.transport.socket.nio.NioSocketConnector.(NioSocketConnector.java:56)

at com.rsa.asoc.transport.nw.session.NextgenConnection.getSocketConnector(NextgenConnection.java:368)

at com.rsa.asoc.transport.nw.session.NextgenConnection.open(NextgenConnection.java:108)

at com.rsa.asoc.transport.nw.session.NextgenConnection.connect(NextgenConnection.java:492)

at com.rsa.asoc.nw.investigate.server.handler.DefaultNextgenConnectionHandler.getNextgenConnection(DefaultNextgenConnectionHandler.java:53)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultNextgenRepositoryEngine.send(DefaultNextgenRepositoryEngine.java:68)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultNextgenRepositoryEngine.send(DefaultNextgenRepositoryEngine.java:51)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultNextgenRepositoryEngine.send(DefaultNextgenRepositoryEngine.java:44)

at com.rsa.asoc.nw.investigate.server.domain.repository.DefaultInvestigateRepository.findLanguages(DefaultInvestigateRepository.java:163)

… 34 common frames omitted

Caused by: java.lang.reflect.InvocationTargetException: null

at sun.reflect.GeneratedConstructorAccessor67.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.apache.mina.core.service.SimpleIoProcessorPool.(SimpleIoProcessorPool.java:198)

… 45 common frames omitted

Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector.

at org.apache.mina.transport.socket.nio.NioProcessor.(NioProcessor.java:64)

… 49 common frames omitted

Caused by: java.io.IOException: Too many open files

at sun.nio.ch.IOUtil.makePipe(Native Method)

at sun.nio.ch.EPollSelectorImpl.(EPollSelectorImpl.java:65)

at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:36)

at java.nio.channels.Selector.open(Selector.java:227)

at org.apache.mina.transport.socket.nio.NioProcessor.(NioProcessor.java:62)

… 49 common frames omitted


아래 메세지들을 봤을 때, 해당 어플리케이션에서 file들을 너무 많이 사용해서 발생한 것으로 보입니다.

Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector.

Caused by: java.io.IOException: Too many open files


어플리케이션이 파일을 적절하게 관리하고 있는지 확인을 하여야 합니다.(파일을 사용 뒤 제대로 close를 하는 지)

어플리케이션에 문제가 없다면, 시스템에서 파일 limit 값을 증가시켜 줍니다. 리눅스의 경우는 ulimit을 확인 하면 됩니다.


# ps -ef | grep java 

로 해당 java 프로그램의 PID를 확인하고,

# cd /proc/PID/fd

# ls -l | wc -l 

을 통해서 해당 PID가 오픈한 파일의 수를 확인합니다.


ulimit -Hn과 ulimit -Hs를 통해서 ulimit 값을 확인하고, 적절하게 조절을 해주면 됩니다.

해당 값은 /etc/security/limits.conf 에서 수정이 가능합니다.


java 어플리케이션에서 따로 ulimit값이 설정 될 경우 리눅스에서 설정된 ulimit값 보다 우선하게 되니, 이 부분도 확인하셔야 합니다.


728x90
반응형