Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

too many open files

Status
Not open for further replies.

AngelaRobert

Programmer
May 14, 2003
1
CA
The application I'm working with works on WSAD V4 but not on V5. I'm
getting a too many open files error. This occurs when doing multiple
file transformations (XSD/XSLT). Some of the XSD files being
transformed have multiple imports. The number of XSD files
transformed is around 350 files.
Is there a way to close Files, or StreamSource's. I've set them to
null after the transform, but that doesn't seem to help. Also, when
this happens I have to restart WSAD. Its strange that this does not
occur on Version 4. (Note: I am using the Version 4 Test Server in WSAD 5)

Thanks,
Angela

code:
Source xslSource = new StreamSource(stylesheet);
TransformerFactory transFact = TransformerFactory.newInstance();
Templates templates = transFact.newTemplates(xslSource);

for (int i=0; i<msgs.length; i++)
{
File htmFile = new File(toPath, msgs + &quot;_v&quot; + version + &quot;.htm&quot;);
File xsdFile = new File(msgPath, msgs + &quot;.xsd&quot;);

if (!htmFile.exists())
{
StreamSource sourceXSD = new StreamSource(xsdFile);
StreamResult resultHTM = new StreamResult(htmFile);
Transformer trans = templates.newTransformer();
trans.setParameter(&quot;docpath&quot;, msgPath.getAbsolutePath() +
System.getProperty(&quot;file.separator&quot;));

trans.transform(sourceXSD, resultHTM); <----------------FAILS
HERE
xsdFile = null;
htmFile = null;
sourceXSD = null;
resultHTM = null;
}
}

File[] docs = toPath.listFiles();

BatchDistributionUtil.zipFiles(docs, new File(toPath,
&quot;documentation.zip&quot;));



*** Starting the server ***
IBM WebSphere Application Server, Release 4.0.4
Advanced Single Server Edition for Multiplatforms
Copyright IBM Corp., 1997-2001

************ Start Display Current Environment ************
WebSphere AEs 4.0.4 ptf40230.02 running with process name
localhost/Default Server and process id 1504
Host Operating System is Windows 2000, version 5.0
Java version = J2RE 1.3.1 IBM Windows 32 build cn131w-20020710 ORB130
(JIT enabled: jitc), Java Compiler = jitc, Java VM name = Classic VM
server.root = D:\Program Files\IBM\WebSphere Studio\runtimes\aes_v4
Java Home = D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4\java\jre
ws.ext.dirs = D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/java/lib;D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/classes;D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/lib;D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/lib/ext;D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/web/help;D:/Program Files/IBM/WebSphere
Studio/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.0.2/runtime/wasListener.jar;D:/Program
Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.webservice_5.0.2/runtime/worf.jar
Classpath = D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/properties;D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/lib/bootstrap.jar;D:/Program
Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.0.2/runtime/wteServers.jar;D:/Program
Files/IBM/WebSphere Studio/wstools/eclipse/plugins/com.ibm.etools.websphere.tools.common_5.0.2/runtime/wasToolsCommon.jar
Java Library path = D:\Program Files\IBM\WebSphere
Studio\runtimes\aes_v4/bin;D:\Program Files\IBM\WebSphere
Studio\eclipse\jre\bin;.;C:\WINNT\System32;C:\WINNT;D:\Program
Files\IBM\WebSphere Studio\runtimes\base_v5\bin;D:\Program
Files\IBM\WebSphere MQ\Java\bin;D:/Program Files/IBM/WebSphere
MQ/WEMPS\bin;D:\Program Files\IBM\WebSphere
MQ\Java\lib;D:\oracle\ora81\bin;C:\Program
Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;D:\Program
Files\Hummingbird\Connectivity\7.00\Accessories\;d:\Program
Files\Rational\ClearQuest;d:\unixtools;D:\Program Files\IBM\WebSphere
MQ\bin;D:\Program Files\IBM\WebSphere
MQ\WEMPS\bin;C:\jdk1.3.1_02\bin;C:\Tools\Ant\bin;C:\Program
Files\Microsoft Visual Studio\Common\VSS\win32
Current trace specification = *=all=disabled
************* End Display Current Environment *************
[5/14/03 10:32:51:750 EDT] 67195e54 Server U Version : 4.0.4
[5/14/03 10:32:51:766 EDT] 67195e54 Server U Edition: Advanced
Single Server Edition for Multiplatforms
[5/14/03 10:32:51:766 EDT] 67195e54 Server U Build date: Thu
Sep 05 00:00:00 EDT 2002
[5/14/03 10:32:51:766 EDT] 67195e54 Server U Build number:
ptf40230.02
[5/14/03 10:32:54:391 EDT] 67195e54 DrAdminServer I WSVR0053I: DrAdmin
available on port 7000
[5/14/03 10:32:54:516 EDT] 67195e54 ResourceBinde I WSVR0049I: Binding
Session Persistence datasource as jdbc/Session
[5/14/03 10:32:55:922 EDT] 67195e54 ServletEngine A SRVE0161I: IBM
WebSphere Application Server - Web Container. Copyright IBM Corp.
1998-2001
[5/14/03 10:32:56:016 EDT] 67195e54 ServletEngine A SRVE0162I: Servlet
Specification Level: 2.2
[5/14/03 10:32:56:016 EDT] 67195e54 ServletEngine A SRVE0163I:
Supported JSP Specification Level: 1.1
[5/14/03 10:32:56:172 EDT] 67195e54 ServletEngine A SRVE0167I: Session
Manager is Configured - Initializing...
[5/14/03 10:32:56:312 EDT] 67195e54 CacheManager A DYNA0011E: Servlet
cache file dynacache.xml not found; caching is disabled
[5/14/03 10:32:56:391 EDT] 67195e54 ServletEngine A SRVE0169I: Loading
Web Module: IBM Universal Test Client.
[5/14/03 10:32:56:906 EDT] 67195e54 WebGroup I SRVE0091I:
[Servlet LOG]: JSP 1.1 Processor: init
[5/14/03 10:32:56:938 EDT] 67195e54 WebGroup I SRVE0091I:
[Servlet LOG]: SimpleFileServlet: init
[5/14/03 10:32:57:297 EDT] 67195e54 ServletEngine A SRVE0169I: Loading
Web Module: RPM Open Message Usage.
[5/14/03 10:32:57:703 EDT] 67195e54 WebGroup I SRVE0091I:
[Servlet LOG]: JSP 1.1 Processor: init
[5/14/03 10:32:57:703 EDT] 67195e54 WebGroup I SRVE0091I:
[Servlet LOG]: SimpleFileServlet: init
[5/14/03 10:32:57:734 EDT] 67195e54 WebGroup I SRVE0091I:
[Servlet LOG]: InvokerServlet: init
[5/14/03 10:32:57:844 EDT] 67195e54 HttpTransport A SRVE0171I:
Transport http is listening on port 8,083.
[5/14/03 10:32:57:922 EDT] 67195e54 Server A WSVR0023I: Server
Default Server open for e-business
[5/14/03 10:33:34:438 EDT] 8275e5a WebGroup I SRVE0091I:
[Servlet LOG]: MsgSearch: init
java.lang.ArrayIndexOutOfBoundsException: 498
at org.apache.xml.dtm.ref.DTMManagerDefault.release(DTMManagerDefault.java(Compiled
Code))
at org.apache.xpath.XPathContext.release(XPathContext.java:227)
at org.apache.xpath.objects.XRTreeFrag.destruct(XRTreeFrag.java:192)
at org.apache.xpath.objects.XRTreeFrag.finalize(XRTreeFrag.java:142)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Finalizer.java(Compiled
Code))
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java(Compiled
Code))
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java(Compiled
Code))
org.apache.xml.utils.WrappedRuntimeException: d:\Program
Files\IBM\WebSphere Studio\RPMOpen_MsgUsage\Web
Content\temp\400\AbstractMessageData.xsd (Too many open files)
at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java(Compiled
Code))
at org.apache.xpath.SourceTreeManager.parseToNode(SourceTreeManager.java(Compiled
Code))
at org.apache.xpath.SourceTreeManager.parseToNode(SourceTreeManager.java(Compiled
Code))
at org.apache.xpath.SourceTreeManager.getSourceTree(SourceTreeManager.java(Compiled
Code))
at org.apache.xalan.templates.FuncDocument.getDoc(FuncDocument.java(Compiled
Code))
at org.apache.xalan.templates.FuncDocument.execute(FuncDocument.java(Compiled
Code))
at org.apache.xpath.XPath.execute(XPath.java(Compiled Code))
at org.apache.xalan.templates.ElemWithParam.getValue(ElemWithParam.java(Compiled
Code))
at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemIf.execute(ElemIf.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java(Compiled
Code))
at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemIf.execute(ElemIf.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemTemplate.execute(ElemTemplate.java(Compiled
Code))
at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.transformToRTF(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemWithParam.getValue(ElemWithParam.java(Compiled
Code))
at org.apache.xalan.templates.ElemCallTemplate.execute(ElemCallTemplate.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java(Compiled
Code))
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2012)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1175)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:642)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1092)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1070)
at com.rpm.ui.msgusage.core.Documentation.SaveDocs(Documentation.java:161)
at com.rpm.ui.msgusage.core.server.MsgSearch.doPost(MsgSearch.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:678)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:331)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:117)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:154)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:323)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
[5/14/03 10:34:55:547 EDT] 8275e5a SystemOut U
java.lang.Exception: Save document error:
org.apache.xalan.res.XSLTErrorResources
java.lang.Exception: Save document error:
org.apache.xalan.res.XSLTErrorResources
at com.rpm.ui.msgusage.core.Documentation.SaveDocs(Documentation.java:178)
at com.rpm.ui.msgusage.core.server.MsgSearch.doPost(MsgSearch.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:678)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:331)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:117)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:154)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:323)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
 
Hi, what you need to do is to close all your streams in a finally block e.g
code:
Source xslSource = new StreamSource(stylesheet);
TransformerFactory transFact = TransformerFactory.newInstance();
Templates templates = transFact.newTemplates(xslSource);

for (int i=0; i<msgs.length; i++)
{
File htmFile = new File(toPath, msgs + &quot;_v&quot; + version + &quot;.htm&quot;);
File xsdFile = new File(msgPath, msgs + &quot;.xsd&quot;);

if (!htmFile.exists())
{
StreamSource sourceXSD = new StreamSource(xsdFile);
StreamResult resultHTM = new StreamResult(htmFile);
Transformer trans = templates.newTransformer();
trans.setParameter(&quot;docpath&quot;, msgPath.getAbsolutePath() +
System.getProperty(&quot;file.separator&quot;));

trans.transform(sourceXSD, resultHTM); <----------------FAILS

//**********Preferable close in a finally block **********
sourceXSD.close();
resultHTM.close();
}
}

File[] docs = toPath.listFiles();
//Also make sure you close any Streams you open in your
//BatchDistributionUtil.zipFiles method


BatchDistributionUtil.zipFiles(docs, new File(toPath,
&quot;documentation.zip&quot;));

****** I hope this helps *****
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top