How do you serialize a subclass of Exception?
Here is my exception:
@XmlType
public static class ValidationFault extends Exception {
public ValidationFault() {
}
}
I have tried all sorts of variations on using @XmlTransient and @XmlAccessorType, but JAXB continually tries to serialize the getStackTrace/setStackTrace pair, which can't be done.
How do I tell JAXB to ignore all the fields on the parent?
I solved this with the information at: http://forums.java.net/jive/thread.jspa?messageID=256122
You need to initialize your JAXBContext with the following config (where jaxbObj is the object to serialize):
You could use an XmlAdapter to handle the marshalling/unmarshalling yourself. Something like this: