• Post Reply Bookmark Topic Watch Topic
  • New Topic

Too Many Files Open Error  RSS feed

 
anand rohit
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting this error for long time at different places now at this place i'm not able to find any open stream which is not closed:
<stackTrace><![CDATA[java.io.IOException: Too many open files
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.><init>(Unknown Source)
at com.i2.xcore.util.ClassPath.getInputStream(ClassPath.java:156)
at com.i2.xcore.xrules.xmlform.LoadXMLFileStatement.execute(LoadXMLFileStatement.java:33)

At line 33 of this method i have:
public void execute(RuleContext context) throws XcoreException
{
InputStream ip = null;
try
{
String fileName = (String) rhs_.getValue(context, false) ;
ClassPath cp = ClassPath.getDefaultClassPath() ;
<line 33> ip = cp.getInputStream(fileName) ;
XMLform ret = XMLform.toXML(ip) ;
lhs_.setValue(context, ret) ;
ip.close() ;
}

Can anyone help me out to get rid of this problem
 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Check old logs,there could be some open streams because of some exception occurring before the close is called. You can close you stream in finally block.

Jhakda
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
 
anand rohit
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks folks but i've already included finally clause in the programme which i didn't mention before.
finally
{
try
{
if ( ip != null)
ip.close();
}
catch(Exception e)
{
context.getOmxContext().getLogger().logException("Error Closing file stream", e);
}
}
and then i was getting error at line 33 as per the stackTrace.
Moreover in getInputStream method i'm using is = new FileInputStream(aFile); to load file and after some processing where no stream is get opened i'm using following thing to get back file in ip = cp.getInputStream(fileName) ;
if( is == null )
throw new IOException("File <"+fileName+"> not found in CLASSPATH.");

return is;
Since I can't close this 'is' in called method and calling method too and there is no need to close this too....
So, what else can be happen to get rid of this problem....Since it's not the OS problem as i have checked it also.
Please suggest what else can i do to remove this problem......i'm using jdk1.4
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"taurean thought " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!