Reputation: 293
I do have an object hierarchy which i want to transform from Java objects into xml using the "import javax.xml.bind.Marshaller". My java class files are enoded in "Cp1252" and i cannot change this.
After i set a property to something like "München" and transform it into xml, the result is M?nchen, so something with the encoding is wrong :-)
On creation of my java class files, everything seems to be ok since the value during the getCity looks fine. In the setCity-Method, called by XMLDirectMapping.setAttributeValueInObject, the vity value is already broken: "Mnchen".
I tried a few different values to set with the property Marshaller.JAXB_ENCODING, but since this is the output encoding i don't ge this working.
My assumption is that the error is must have something to do with the default encoding of my vm or the encoding of the libraries. But since I do not have any idea it would be great if someone of you had this problem before.
Please let me know if you need any further informations to solve it. It would be really great NOT to spend half a day or more just because of an issue like this.
Thanks
Upvotes: 1
Views: 527
Reputation: 149047
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-22) expert group.
On creation of my java class files, everything seems to be ok since the value during the getCity looks fine. In the setCity-Method, called by XMLDirectMapping.setAttributeValueInObject, the vity value is already broken: "Mnchen".
Based on this statement I can tell that you are using the EclipseLink MOXy implementation of JAXB (JSR-222).
Where are you seeing that the value is encoded incorrectly? Sometimes a value appears to be incorrectly encoded in an editor/debugger but in reality it is correct. If you marshal the result to a file do you get the correct result?
Upvotes: 1
Reputation: 1626
Without code it is difficult to determine a possible small mistake even if you meant it to be correctly implemented.
First I would like to suggest that you use UTF-8 as encoding as it is more standard and if I am not mistaken more cross-platform, but this is the default.
Secondly I would check if the generated file indeed contains in its xml tags that it is encoded with that encoding.
Thirdly you can change the encoding using the system property jaxb.encoding
so launch your app with -Djaxb.encoding=Cp1252 not Marshaller.JAXB_ENCODING !
Upvotes: 1