I m使用标准javax.xml包,将一些XML文件编成一个支机。 我的法典如下:
try
{
// Prepare parser
DocumentBuilder documentBuilder = documentBuilderFactory
.newDocumentBuilder();
Document document = documentBuilder.parse(file.getAbsolutePath()); // This is line 397
XPath xPath = xPathFactory.newXPath();
...
}
catch(IOException e) { ... }
单张文件BuilderFactory用多个透镜获得,就像单张XPathFactory一样,我认为这是可以接受的使用。 在使用上述法典对XML档案进行分类时,我偶尔会发现以下错误。
java.io.IOException: Bad file descriptor
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:229)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:229)
at java.io.BufferedInputStream.read(BufferedInputStream.java:246)
at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at mypackage.MyXmlParser.parseFile(MyXmlParser.java:397)
at mypackage.MyXmlParser.access$500(MyXmlParser.java:51)
at mypackage.MyXmlParser$1.call(MyXmlParser.java:337)
at mypackage.MyXmlParser$1.call(MyXmlParser.java:328)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:284)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:799)
我偶尔会(约10%的时间)看到以下补充案文:
Caused by:
java.io.IOException: Bad file descriptor
at org.apache.xml.serializer.ToStream.flushWriter(ToStream.java:260)
at org.apache.xml.serializer.ToXMLStream.endDocument(ToXMLStream.java:191)
at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:983)
at org.apache.xml.serializer.TreeWalker.traverse(TreeWalker.java:174)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:410)
... 9 more
当我对档案进行人工检查时,我看不到失败的档案和通过的文件之间没有任何区别。 我可以确认,通行证是有效的XML,没有特殊性或过早终结。
是否有任何人知道为什么会发生这种情况,我如何能够避免这种情况?
> java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pxa64dev-20061002a (SR3) )
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Linux amd64-64 j9vmxa6423-20061001 (JIT enabled)
J9VM - 20060915_08260_LHdSMr
JIT - 20060908_1811_r8
GC - 20060906_AA)
JCL - 20061002