I have the following code:
javax.xml.bind.Marshaller m = ...
java.io.OutputStream outputStream = ...
Object jaxbElement = ...
m.marshal(jaxbElement, outputStream);
It works fine.
I also have the following code:
javax.xml.bind.Marshaller m = ...
java.io.BufferedWriter writer = ...
Object jaxbElement = ...
m.marshal(jaxbElement, writer);
Executing the call to marshal in this case gives the following exception:
javax.xml.bind.MarshalException
- with linked exception:
[java.io.IOException: Unrecognizable signature: "<?xml version="1.0" e".]
jaxbElement in both cases is the same.
Why would the first example work, while the second example fails?
I haven’t been able to reproduce the exception you are seeing, the following works for me.
Foo
Demo
Output