问题描述
我越来越奇怪文件过早结束".最近几天在我们的一台服务器上例外.same 配置 XML 在另一台服务器上工作正常.我们在这两台服务器上都使用 Tomcat 5.0.28.这段代码已经工作了很长时间(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. :(
我能看到的唯一区别是 Java 版本 -
The only difference I can see is in Java versions -
问题服务器java版本1.6.0_16"Java(TM) SE 运行时环境 (build 1.6.0_16-b01)Java HotSpot(TM) 64 位服务器 VM(内部版本 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 运行时环境 (build 1.6.0_07-b06)Java HotSpot(TM) 64 位服务器 VM(内部版本 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)
这是已经工作了几年的 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)
我已经尝试过验证 XML 并没有发现任何错误.知道我还能在哪里寻找可能的问题吗?
I have already tried validating XML and found no errors there. Any idea where else can I look for possible problem?
任何指针将不胜感激!
TIA,- 马尼什
推荐答案
解决了.问题出在其他地方.cron 作业中的另一个代码是将 XML 截断为长度为 0 的文件.我已经处理好了.
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 的文件过早结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!