'JBOSS 6.0.0 Server Crashed when i use AJP Protocol - Too many open files

J BOSS 6.0.0 Server Crashed when i use AJP Protocol. System showing the below exception continuously.

2012-08-21 16:12:51,750 ERROR [org.apache.tomcat.util.net.JIoEndpoint] (ajp-0.0.0.0-8009-Acceptor-0) Socket accept failed: java.net.SocketException: Too many open files
at java.net.PlainSocketImpl.socketAccept(Native Method) [:1.6.0_24]
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408) [:1.6.0_24]
at java.net.ServerSocket.implAccept(ServerSocket.java:462) [:1.6.0_24]
at java.net.ServerSocket.accept(ServerSocket.java:430) [:1.6.0_24]
at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61) [:6.0.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:343) [:6.0.0.Final]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]


Solution 1:[1]

Issue is because of max threads & connectionTimeout set in the Server.xml in the JBOSS server.

AJP Protocol's connectionTimeout default value is infinite.

so, connectionTimeout value set to 120000 (2 minutes).

So, problem (Too many open files) never replicated. Its always better to set the optimal configuration setting instead of default values.

To assist this issue some other configuration changes has been made. those are,

"max threads" value for ajp protocol changed from 1500 to 150.

"ulimit -n" value has changed from 1024 to 8192.

Solution 2:[2]

  • check the maximum number of fd in system by entering cat /proc/sys/fs/file-max if you have 65535 it should be ok but you can increase it to 200000
  • check the ulimit by entering 'ulimit -n' , on my side that gaves 1024, so i increase it in the file /etc/security/limites.conf and add :

    * soft nofile 2048

    * hard nofile 2048

Finally you can check the fd byt entering lsof -p xxx|wc -l

all those explanation come from this which saves my life each time i faced this issue.

Solution 3:[3]

The problem with AJP is that its connectionTimeout default value is infinite. To resolve the issue I suggest that you switch to http or even better https.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mallikarjuna Reddy
Solution 2
Solution 3 Yassir Khaldi