• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Too Many Files Open Error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at our FAQ, How do I fix exceptions that indicate "Too many open files"?
 
anand rohit
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic