0 Replies Latest reply on Apr 19, 2013 4:47 AM by joshd

    How to "Json-transient" properties with RESTeasy with Seam 2.3 on JBoss 7.1.1

    joshd Newbie

      How to achieve that some properties are ignored in the JSON-output (like XmlTransient for XML-output)?

      @GET @Path("/{companyId}") @Produces(MediaType.APPLICATION_JSON)

      public Company getCompany(@PathParam("companyId") long id);

      I've been playing around with the RESTeasy-support in Seam 2.3 deployed as an EAR on a JBoss 7.1. I started by adding the same dependencies to my ejb-project as in the Seam-restbay-example. It is basically working fine for @Produces(MediaType.APPLICATION_XML), where all properties annotated with @XmlTransient are ignored, in order to prevent some LazyInitialisationExceptions. But how to achieve this behavior for @Produces(MediaType.APPLICATION_JSON)?

      I've read Seam uses Jettison by default, which uses the @XmlTransient annotation for both, XML and JSON (because technically it transforms from XML -> to JSON). But I get a "Caused by: org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer" which indicates that in fact it is using Jackson..? For Jackson there is the annotation like @JsonIgnore, but having the same maven dependencies like restbay - this "cannot to be resolved to a type", its just unknown.

      /**

      * @return the contact

      */

      @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY)

      @XmlTransient  // working for producing XML but not for JSON

      //@JsonIgnore  = unknown type

      public Contact getContact() {

          return contact;

      }

      Anyone any experiences or hints on that?

      thanks