I develop application run in Websphere work manager. work manager is used to run thread in the webpshere applications erver.
Every 5 minutes my thread try to get some data from MySQL database from the different host from the application server machine.
When the Host of MySql database turned off, The work manager always try to connect to MySQL database and I know my program will always get exception connection failure. this is the exception: com.mysql.jdbc.CommunicationsException:
Communications link failure due to underlying exception
But, over time my program get exception as follows:
java.sql.SQLException: The application requester cannot establish the connection. (Too many open files)
and this exception make my application server crash:
[8/2/10 9:07:21:613 ICT] 00000d54 prefs W Could not lock User prefs. Unix error code 24.
[8/2/10 9:07:21:613 ICT] 00000d54 prefs W Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
I need suggestion how to fix this problem and prevent my application being crash ????
WorkEnvironment:
Operation System AIX
Application Server Webpshere 7.0
It sounds like you have a file descriptor leak.
Some part of your code (or some other code running on the machine) is creating more and more file handles, including sockets, and is not closing them. Based on your description, it sounds like it’s your code that’s doing this.
I suspect that when you create the socket, you’re not closing it cleanly when an exception is thrown. If you don’t do this, then the socket will stay open and over time you’ll run out of files. Any resource that needs to be closed after use should always be closed in a try-finally block, to ensure that the resource will be closed regardless of the path through the method.
If you don’t think you’re leaking files, use the
lsofutility on the host to see what file handles are being held open by your process, and check that you do legitimately need all of them. I find it unlikely that you have a legitimate reason to exceed the default FD limit of the system.