users@jaxb.java.net

Problem implementing GET REST service due to JAXBException exception

From: Alexander Kress <Alexander.Kress_at_radialpoint.com>
Date: Fri, 9 Jul 2010 11:16:34 -0400

Hello,

 

I am having a really strange problem implementing a REST service. I am
trying receive the following model:

 

    @Data @EqualsAndHashCode(callSuper=false, of={"primaryKey"})

    @Entity @Table(name = "T_UNIQUE_IDENT_TYPE")

    @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

    @XmlRootElement(name="UniqueIdentifierType")
@XmlAccessorType(XmlAccessType.FIELD)

    public class UniqueIdentifierType extends AbstractEntityWithTime
implements Serializable {

        private static final long serialVersionUID = 1L;

        @Id @Basic(optional = false) @Column(name = "F_TYPE_PK")
@XmlTransient

 
@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="S_UNIQUE_IDE
NT_TYPE")
@SequenceGenerator(name="S_UNIQUE_IDENT_TYPE",sequenceName="S_UNIQUE_IDE
NT_TYPE")

        private Long primaryKey;

        @Column(name = "F_NAME", nullable=false, length=50)

        private String typeName;

        @Basic(optional = false) @Column(name = "F_CREATION_TIME")
@Temporal(TemporalType.TIMESTAMP) @XmlTransient

        private Calendar creationTime;

        @Basic(optional = false) @Column(name = "F_LASTMODIFY_TIME")
@Temporal(TemporalType.TIMESTAMP) @XmlTransient

        private Calendar lastModifyTime;

        @JoinColumn(name = "F_UNIT_PK", referencedColumnName =
"F_UNIT_PK") @ManyToOne(optional = false) @XmlTransient

        private SoftwareProviderUnit softwareProviderUnit;

    }

 

My GET REST service has the following signature:

 

                @GET

                @Path("/{name}")

                public UniqueIdentifierType get(@PathParam("unitId")
final Long unitId, @PathParam("name") final String name) throws
WebApplicationException {

 

Whenever I do a call on this GET service I receive 500 error containing

 

    java.lang.AssertionError: JAXBException occurred : 2 counts of
IllegalAnnotationExceptions

 

I was able to trace it down to the following two errors:

 

    javassist.util.proxy.MethodHandler is an interface, and JAXB can't
handle interfaces.

                this problem is related to the following location:

                                at javassist.util.proxy.MethodHandler

                                at private
javassist.util.proxy.MethodHandler
com.rp.central.model.UniqueIdentifierType_$$_javassist_21.handler

                                at
com.rp.central.model.UniqueIdentifierType_$$_javassist_21

    

    javassist.util.proxy.MethodHandler does not have a no-arg default
constructor.

                this problem is related to the following location:

                                at javassist.util.proxy.MethodHandler

                                at private
javassist.util.proxy.MethodHandler
com.rp.central.model.UniqueIdentifierType_$$_javassist_21.handler

                                at
com.rp.central.model.UniqueIdentifierType_$$_javassist_21

 

The weird thing is that if I change the GET method signature to return a
List I get 200 with the JSON view of the object which has all the fields
*except for the typeName field*. I am guessing that the exception is
somehow related to that field. I've tried adding explicit getters such
as

 

    @XmlElement(name="typeName")

    public String getTypeName() {

                return typeName;

    }

 

to try to force it to send the typeName, this gets the type name into
the "List" version of the GET method but still returns 500 for the non
list one. The strange thing is that I have another model which looks
exactly the same as this one and works without any problems. I've been
banging my head against this for a while now, any help will be greatly
appreciated.

 

Thank you.


***********************************************************************

This e-mail and attachments are confidential, legally privileged, may be subject to copyright and sent solely for the attention of the addressee(s). Any unauthorized use or disclosure is prohibited. Statements and opinions expressed in this e-mail may not represent those of Radialpoint.

Le contenu du présent courriel est confidentiel, privilégié et peut être soumis à des droits d'auteur. Il est envoyé à l'intention exclusive de son ou de ses destinataires. Il est interdit de l'utiliser ou de le divulguer sans autorisation. Les opinions exprimées dans le présent courriel peuvent diverger de celles de Radialpoint.