You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Tobbi <to...@systinet.com> on 2002/06/14 12:35:58 UTC
Xerces doesn't close the stream when reading
Hi,
I've found a problem on WebLogic server. I port my application under server and trying to parse files stored directly in .jar file. Using Xerces 2.0 JAXP interfaces I get sometimes an exception that resource wasn't found.
1) my main class is in my.jar
2) in my.jar is also com/my/resource.xml
3) using JAXP
... create DocumentBuilderFactory
... create DocumentBuilder
... URL url = this.getClass().getClassLoader().getResource("com/my/resource.xml")
... documentBuilder.parse(url.externalForm());
notes: factory is static, common for each call
builder is created for each call
in the second or third parsing I get an exception from parse() method that resource is not available
exception comes from URL.openStream() method inside DOMParser
I've found that parse() function CREATES a stream but doesn't CLOSE it!
It seems like sometimes garbage collector erases URL and stream from memory and all is ok, but sometimes exception occurs.
Is this a bug or I've missed some my mistake?
Best regards, Tomas Bouda