How to handle java.net.SocketException: Too many open files

jakarta-ee, socketexception, struts2

Solution

I guess you are on a linux based operating system? It's seems that you need to increase the number of max. file handles per process.

have a look here: http://ehaselwanter.com/en/blog/2009/03/13/tomcat-too-many-open-files/

Problem

Ours is a Struts2 java webapplication, using hibernate 3.5 ORM. When we perfom some parallel actions on the app, we are getting the below exceptions and the java process cpu utilization is at its max. ``` May 15, 2012 12:39:59 AM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408) at java.net.ServerSocket.implAccept(ServerSocket.java:462) at java.net.ServerSocket.accept(ServerSocket.java:430) at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:59) at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:210) at java.lang.Thread.run(Thread.java:662) ``` Please suggest us accordingly.

Original source