English 中文(简体)
Bad file Descriptor IOException in Java using javax.xml
原标题:Bad File Descriptor IOException in Java using javax.xml

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
最佳回答

它像一个同时存在的问题。

错误可能是你向我们展示的法典之外的其他地方。 但是,文件BuilderFactory和XPathFactory I也无法确定,如果它们已经准备好安全;文件没有提及。

关于第一次测试,我建议你将XML文档总编码纳入<条码>同步化{<>>条款。 如果能解决你的问题,那么,这确实是一个多方面的问题。 在这种情况下,你必须找到必须同步的最小部分。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签