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.
The only difference I can see is in Java versions -
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 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)
Here is the Java code that has been working for several years -
And here is the exception.
I have already tried validating XML and found no errors there (updated it from SVN as well). The XML is 108.1 KB in size and comes from local file system.
Any idea where else can I look for the possible problem?
Paul Clapham wrote:You appear to be assuming that the "file" referred to in the "end of file" message is the XML document. Is it not possible that the "file" in question is a DTD or schema which the document refers to?
NO. Unlikely. I am not validating against any schema/DTD.
I should also add that we start 16 jobs through this XML configuration. 12 out of 16 jobs are running fine now, but 4 jobs (despite having valid configuration elements) are just not running and causing parse exception. I have tried moving them up & down the config fine, but just those jobs are having problems. That makes one suspect XML element themselves, but I have carefully examined them and have found that they are absolutely fine.
William Brogden wrote:If this was my problem I would use the SAXParseException methods getLineNumber and getColumnNumber when reporting the exception.
These frequently help me to locate completely unexpected weird problems like yours.
On my local machine, I deliberately introduced an XML error and checked it with the code using SAXParseException, but I found that it didn't give me line number or column number (I thought so) as I didn't have a valid Locator object there.
Jaikiran Pai wrote:How is the InputSource that's being passed to the parser, being created in your application? What does that code look like? Most likely the problem lies there and not in the parsing part.