Discussion Locked

Too many open files Error in java

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I have a java application running on Solaris 2.6 that works fine for a while and then craps out with the following error:

java.io.FileNotFoundException: /tmp/jlaunch.malettd.com.gcm.UPL.UPLMain.props (Too many open files)
java.io.FileNotFoundException: /tmp/jlaunch.malettd.com.gcm.UPL.UPLMain.props (Too many open files)
thr_continue of 0xd42702f8(0) failed: 3 = ESRCH.

At other times I get the following error message:

thr_continue of 0xd543fac8(3) failed: 3 = ESRCH.
thr_continue of 0xd543fa30(-278136652) failed: 3 = ESRCH.
thr_continue of 0xd543f990(-278136652) failed: 3 = ESRCH.
thr_continue of 0xd543fb30(-716965000) failed: 3 = ESRCH.
thr_continue of 0xd543fa78(-716965184) failed: 3 = ESRCH.
thr_continue of 0xd543fb78(0) failed: 3 = ESRCH.
Bus Error
si_signo [10]: Bus Error
si_errno [0]: Error 0
si_code [1]: BUS_ADRALN [addr: 0x3]

stackpointer=D3E21678

This happens even though the limit of the file descriptors is set to 256.

Iam a new java developer, so I am having trouble figuring out what is causing this problem.

Please help.

Thanks.

7 replies

by jp107

I haven't encountered this error personally, but my first response would be to make sure that you are calling close() on all your FileInputStream's and FileOutputStream's that deal with your files. I believe it's the open streams that consume file descriptor resources.

The best way (in my opinion) to ensure that your streams are closed is by enclosing the call to the close() method in a finally block, as follows:

FileInputStream fis = null;
try {

}
} finally{
try {
fis.close();
} catch (IOException ioe) {
// squelch this exception: nothing you
// can really do about it here.
}
}

Hope this helps

by diva_cen2000

hi,

i think ur trying to read file.The exception u have encountered will araised only when the file
ur trying to read is not in the current directory.

while ur trying to read a file u have to specify the directory,the path where the file is located.
if the file is in the same directory no problem.

eg.
consider the file ai.txt is in the directory
c:\windows
or so ..
and ur working in the same directory no need to give the path.
i.e
FileInputStream fin=new FileInputStream("a1.txt")

else
FileInputStream fin=new FileInputStream("c:\windows\a1.txt")
try this out ..

by diva_cen2000

hi,

i think ur trying to read file.The exception u have encountered will araised only when the file
ur trying to read is not in the current directory.

while ur trying to read a file u have to specify the directory,the path where the file is located.
if the file is in the same directory no problem.

eg.
consider the file ai.txt is in the directory
c:\windows
or so ..
and ur working in the same directory no need to give the path.
i.e
FileInputStream fin=new FileInputStream("a1.txt")

else
FileInputStream fin=new FileInputStream("c:\windows\a1.txt")
try this out ..

This discussion is closed to new replies.