What I have is a set of Java classes (close to 25) representing message types. They all inherit from a Message class which I\'d like to be abstract. Each message type adds
Have you tried adding the following to your message class? The @XmlSeeAlso annotation will let the JAXBContext know about the subclasses.
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlRootElement
@XmlSeeAlso(RegMessage.class)
public abstract class Message {
Integer id;
}
Alternate Strategy:
Here is a link to a strategy I have helped people use:
Essentially you have one message object, and multiple individual message payloads. The relationship between the message and payload is handled through a @XmlAnyElement annotation.
Note on Transaction Handling
I noticed that you are handling your own transactions. Have you considered implementing your JAX-RS service as a session bean and leverage JTA for your transaction handling? For an example see: