Hi Peter,
The framework tries to instantiate "Shape" while it is abstract. It could be
the result of the annotation @XmlRootElement added to it. Did you try to go
without it?
regards,
exxos.
On Thu, Sep 9, 2010 at 11:23 AM, Peter Hill <Peter.Hill_at_tudor.com> wrote:
> Hi,
>
>
>
> I am having trouble un-marshalling a list of objects when the object type
> in the list has a property which is defined as an abstract class.
>
>
>
> Below is how the classes are defined. Have I done this correctly? The
> server appears to create valid syntax. I have searched the internet for the
> last couple of days but cannot seem to find a solution. If I switch the
> transport protocol to XML I do not have this problem, but unfortunately I
> cannot use this in production.
>
>
>
> I have also included a test case which should show the error.
>
>
>
> @XmlRootElement(name="diagram")
>
> *public* *class* Diagram {
>
>
>
> *private* Shape shape;
>
>
>
> *public* Diagram() {
>
> *super*();
>
> }
>
>
>
> *public* Diagram(Shape shape) {
>
> *super*();
>
> *this*.shape = shape;
>
> }
>
>
>
> *public* Shape getShape() {
>
> *return* shape;
>
> }
>
>
>
> *public* *void* setShape(Shape shape) {
>
> *this*.shape = shape;
>
> }
>
>
>
> }
>
>
>
> @XmlRootElement
>
> @XmlSeeAlso({Square.*class*, Circle.*class*})
>
> *public* *abstract* *class* Shape {
>
>
>
> ..
>
>
>
> }
>
>
>
> @XmlRootElement
>
> *public* *class* Circle *extends* Shape {
>
>
>
> ..
>
>
>
> }
>
>
>
> Error:
>
> [*javax.xml.bind.UnmarshalException*: Unable to create an instance of
> com.diagrams.Shape
>
>
>
> I am using the latest jersey server and client jars to do this, running on
> Jboss 5.1. All other classes are communicated between the client and server
> seamlessly.
>
>
>
> Any help or guidance would be greatly appreciated.
>
>
>
> Many thanks,
>
> Peter
>
>
>
> --
>
> _________________________________________________________
>
> This email, its contents, and any attachments transmitted with it are
> intended only for the addressee(s) and may be confidential and legally
> privileged. We do not waive any confidentiality by misdelivery. If you have
> received this email in error, please notify the sender immediately and
> delete it. You should not copy it, forward it or otherwise use the contents,
> attachments or information in any way. Any liability for viruses is excluded
> to the fullest extent permitted by law.
>
> Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial
> Services Authority (the FSA). TCE is registered as a limited liability
> partnership in England and Wales No: OC340673 with its registered office at
> Great Burgh, Epsom, Surrey, KT18 5XT.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>