Parsing Exception with JAXB 1.0.6 : XML files containing UTF-8 characters
843834Jul 22 2010 — edited Jul 25 2010Hi,
My application is using JAXB 1.0.6 and JDK 1.4, When am trying to parse some XML files which contatining some UTF-8 characters, parsing has failed.
Here is the code which am using
**************************************
Unmarshaller unmarshaller = jc.createUnmarshaller();
unmarshaller.setValidating(bvalidate);
byte[] byteArray = strXMLFile.getBytes();
Object obj = unmarshaller.unmarshal(new ByteArrayInputStream(
byteArray));
this throws the following exception:
****************************************
javax.xml.bind.JAXBException
- with linked exception:
[java.io.UTFDataFormatException: Invalid byte 2 of 2-byte UTF-8 sequence.]
I tried the following also
***************************
Unmarshaller unmarshaller = jc.createUnmarshaller();
unmarshaller.setValidating(bvalidate);
byte[] byteArray = strXMLFile.getBytes();
ByteArrayInputStream source = new ByteArrayInputStream(byteArray);
InputSource input = new InputSource(source);
input.setEncoding("UTF-8");
Object obj = unmarshaller.unmarshal(input);
this throws the following exception:
****************************************
javax.xml.bind.UnmarshalException: Content is not allowed in prolog.
- with linked exception:
[org.xml.sax.SAXParseException: Content is not allowed in prolog.]
Now i need to confirm that the JAXB 1.0.6 is supporting all the UTF-8 character sets.
Please help me if you have come across this kind of problems.
Thanks in advance,