Reputation: 247
I want to know the exact problem of Too many files opened error. I went through google for solution but i could not get why this problem happens and how to solve the problem. is that some thing about ulimit value ?
stack error : SEVERE: Socket accept failed java.net.SocketException: Too many open files at java.net.PlainSocketImpl.socketAccept(Native Method) at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398) at java.net.ServerSocket.implAccept(ServerSocket.java:530) at java.net.ServerSocket.accept(ServerSocket.java:498) at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61) at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:352) – user2883376 yesterday
Linux server and this is my last update in the code to get messages based on language. ApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml"); name = context.getMessage(key, null, locale); return name;
Any suggestions on this error ?
Upvotes: 2
Views: 5432
Reputation: 57
Although if "ulimit" is raised at some point down the line tomcat stops causing same error.
So in order to avoid this you can check list of open files for the application user on Linux using command "lsof -u username" or simply "lsof" and see if code related files are open ( eg..properties files ) if so kill those specific files using # kill -9 lsof -t -u username
command for that specific tomcat user.
You need to fix your code to load those files writing simply in a static block of your classes. So that only one file loads even if multiple hits are made by any number of users.
Now you can re check after deploying new changes with the same lsof
command and see. Only one file will be seen. This will permanently fix your issue without raising the ulimit each time.
Upvotes: -2
Reputation: 310883
The problem is almost certainly that you are leaking file handles somewhere in your code. I have Tomcats that stay up for months at a time without encountering this.
Upvotes: 4