Wednesday, June 13, 2007

crimson vs xerces

We use iBatis + spring in our projects..
When i tried to launch a testcase in one of our new projects a strange error happened.

SAXParseException: Document root element is missing

Crimson parser that comes default with jdk1.4 is the reason behind it.
jdk1.5 and xerces parses same xml documents fine.
A google search reveals that i am not alone too..

Edit: The root cause was that spring xml was encoded in UTF-8 with high BOM.
When i manually converted documents encoding to US-ASCII (properties->encoding)
three strange characters revealed themselves at the very beginning of file. Deleting them solved the problem. Lesson learned: Sun's Crimson parser does not support BOM markers.

No comments: