aspose file tools*
The moose likes XML and Related Technologies and the fly likes SAXParseException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "SAXParseException" Watch "SAXParseException" New topic
Author

SAXParseException

Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Actually i am getting exception "org.xml.sax.SAXParseException: Premature end of file" while after reading xml file.
Sorry i too dont know whats the reason for that.
Can any one help to find the solution.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That means the parser got to the end of the file without seeing the end of the XML document. That would mean the last part of the document is missing.
Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Paul Clapham wrote:That means the parser got to the end of the file without seeing the end of the XML document. That would mean the last part of the document is missing.


Thanks, but this file successfully read and parsing done in solaris but not in linux.
i mean, i used the same xml and same java code for reading the xml file in both solaris and linux. But i didnt face this error in solaris, i faced only in linux.
Are parsers varied from one java version another java version?
Are parsers depends upon apache version?

Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Mani Raju wrote:
Paul Clapham wrote:That means the parser got to the end of the file without seeing the end of the XML document. That would mean the last part of the document is missing.


Thanks, but this file successfully read and parsing done in solaris but not in linux.
i mean, i used the same xml and same java code for reading the xml file in both solaris and linux. But i didnt face this error in solaris, i faced only in linux.
Are parsers varied from one java version another java version?
Are parsers depends upon apache version?

Is the process of parsers identifying end of xml file different from one jdk version to another version or one apache version to another version?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 507
    
    3
But i didnt face this error in solaris, i faced only in linux.

That would be symptomatic to bugs... A search on bug reports on "org.xml.sax.SAXParseException: Premature end of file" results in plenty of instances filed. One of them is this.
https://netbeans.org/bugzilla/show_bug.cgi?id=217431

But before jumping to conclusion and as a consequence awaiting an official fix doing nothing in the meantime, make some updates at least or to take notes on the difference being used in the two os platforms.
Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Yes, i noted all the differences between linux and solaris.

This same code and xml files working correctly for the remaining modules except one module, because of this exception.

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 javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208).

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
If this was my problem I would use the getColumnNumber() and getLineNumber() methods of SAXParseException to see where the parser thinks it hit end of file.

Bill
Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
William Brogden wrote:If this was my problem I would use the getColumnNumber() and getLineNumber() methods of SAXParseException to see where the parser thinks it hit end of file.

Bill

Thanks, i will try in this way. I mean i will use above mentioned methods to find where this exception raised.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAXParseException