問題描述
我越來越奇怪文件過早結(jié)束".最近幾天在我們的一臺服務器上例外.same 配置 XML 在另一臺服務器上工作正常.我們在這兩臺服務器上都使用 Tomcat 5.0.28.這段代碼已經(jīng)工作了很長時間(7 年以上),只是在最近的服務器崩潰之后,我們在其中一臺服務器上遇到了這個問題.XML 和 Java 解析代碼沒有變化.:(
I am getting very strange "Premature end of file." exception for last few days on one of our servers. The same configuration XML works fine on another server. We are using Tomcat 5.0.28 on both these servers. This code has been working for ages (7+ years), only after recent server crash, we faced this problem on one of the servers. There is no change in XML as well as Java parsing code. :(
我能看到的唯一區(qū)別是 Java 版本 -
The only difference I can see is in Java versions -
問題服務器java版本1.6.0_16"Java(TM) SE 運行時環(huán)境 (build 1.6.0_16-b01)Java HotSpot(TM) 64 位服務器 VM(內(nèi)部版本 14.2-b01,混合模式)
Problem Server java version "1.6.0_16" Java(TM) SE Runtime Environment (build 1.6.0_16-b01) Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
工作服務器java版本1.6.0_07"Java(TM) SE 運行時環(huán)境 (build 1.6.0_07-b06)Java HotSpot(TM) 64 位服務器 VM(內(nèi)部版本 10.0-b23,混合模式)
Working Server java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06) Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
這是已經(jīng)工作了幾年的 Java 代碼 -
Here is the Java code that has been working for several years -
private void readSource(final InputSource in ) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(in);
Element elt = doc.getDocumentElement();
this.readElement( elt );
} catch ( Exception ex ) {
ex.printStackTrace();
throw new ConfigurationException( "Unable to parse configuration information", ex );
}
}
這里是個例外.
[Fatal Error] :-1:-1: Premature end of file.
org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at com.circus.core.Configuration.readSource(Configuration.java:706)
我已經(jīng)嘗試過驗證 XML 并沒有發(fā)現(xiàn)任何錯誤.知道我還能在哪里尋找可能的問題嗎?
I have already tried validating XML and found no errors there. Any idea where else can I look for possible problem?
任何指針將不勝感激!
TIA,- 馬尼什
推薦答案
解決了.問題出在其他地方.cron 作業(yè)中的另一個代碼是將 XML 截斷為長度為 0 的文件.我已經(jīng)處理好了.
This is resolved. The problem was elsewhere. Another code in cron job was truncating XML to 0 length file. I have taken care of that.
這篇關于org.xml.sax.SAXParseException:*VALID* XML 的文件過早結(jié)束的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!