I am following the blog post : http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-xsitype.html
and I have done all the same things, except that my subclasses are not public and are in the same file as that of the abstract class file. I get java.lang.InstantiationException exception javax.xml.bind.UnmarshalException: Unable to create an instance of org.apache.ambari.server.state.DependencyConditionInfo - with linked exception: [java.lang.InstantiationException] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent( UnmarshallingContext.java:647)
EDIT
When I use @XmlSeeAlso I need to provide a default constructor, due to which I am not able to initialize the data member of the subclass.
Can anyone help me find a solution? Thanks
Why this is failing is because Jaxb will attempt to create an instance of User. which is abstract and therefore the failure.
On your abstract class add the annotations
see the javadoc for each(XmlTransient, XmlSeeAlso)
What this will do is prevent jaxb from trying to initialize your abstract class.
The only downside to this method I found is there will be extra namespace information added to the xml that gets created.
Solved by @wyche5000