I fully understand the error "An invalid XML character (Unicode: 0x3) was found"
Caused by: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x3) was found in the element content of the document. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[na:1.8.0_111] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177) ~[na:1.8.0_111] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400) ~[na:1.8.0_111] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[na:1.8.0_111] at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1472) ~[na:1.8.0_111] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2923) ~[na:1.8.0_111]
But I cannot believe my eyes that it is marshalled with this character in the first place.
I've marshalled the class that contained portions of .gz file in it, and the marshalling was successful. When I tried to unmarshal it, it gave me this error.
The marshaller and unmarshaller I used were from /com/sun/xml/internal/bind/v2/runtime/ -- rt.jar.
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(object, stringWriter);
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.unmarshal(new StringReader(stringWriter.toString()));
This is obvious reflexivity issue and I don't know how to deal with it.
Anyone who had the same issue, please advise how to overcome it, hopefully, without marshaller change.
P.S. From my understanding, marshallers should always be reflexive and do not marshal things that it cannot unmarshal. It's a shame that rt.jar one is not.
Third thing I forgot about it...
There are characters invalid to be in the XML as string and must be escaped as:
If any of your string can have them they must be either escaped or included in CDATA if they are not in attributes.
see here: Invalid Characters in XML