• Post Reply Bookmark Topic Watch Topic
  • New Topic

RESTEasy Client Proxy, Jackson, JSON deserialization - Deserialization fails

 
Kevin Thorne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have got, I think personally, the oddest bug. Even if my JSON specifies a type, Jackson's deserializer still deserializes it into LinkedHashMap

I'm using RESTEasy (JAX-RS JBoss impl) on both the server and client I'm developing, transferring everything in JSON (using Jackson JAX-RS provider). The server and client share common interfaces (as expected).

The cool thing I tried to do with my REST services was to wrap whatever Entity into its interfaces, making CRUD operations transparent and written in a common abstract implementation.

In simpler words, and using code, I've done the following:


is the central interface for any other REST service that will be needing CRUD operations on Entities (User, UserGroup, etc).


Now, for my UserGroup entity class, another interface is made to extend the central interface to specify CRUD ops, plus some helper methods:


On the server side, the UserGroup Server REST service is implemented like this:


Notice the ServerService<ENTITY, EJBSERVICE> extension. This covers the previously stated central MyRestService<ENTITY> interface, since all my EJB stateless beans follow a similar CRUD framework (central interface with CRUD, subinterface with procedural helper methods):



"Alright, I've been reading this for five minutes, what the issue?"

The client takes advantage of RESTEasy proxy interfaces, where you can jam in a properly annotated JAX-RS interface and you'll make calls to the server by just calling the method.

I do similar implementations of the interfaces on the client side so I can cache and all sorts of things.

The Problem

At some point in the client, I call:
Client Log:



Why on earth is LinkedHashMap being generated from that JSON I received in the response? I used @JsonTypeInfo to add in the type into the serialized object. I still have quite the investigation to do, I'll be attempting to navigate RESTEasy proxy interfaces to hopefully get down to the Jackson provider.

Any idea what's going on here? I just feel like the type info shouldn't have been ignored.

Totally willing to clarify and edit, I know this was quite the explosion on my keyboard and here on the forums. I'm hoping to tap into the knowledge of those who know Jackson and Java Generics better than I do.
 
Kevin Thorne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Solution

A simple lesson in RESTful services altogether. A PUT method should not (and won't) return anything other than Response object. Making my insert method a POST HTTP method fixed it.
 
Kevin Thorne
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone do my a favor and mark this UNRESOLVED? I'm still running into this issue. The Jackson Provider is the one returning a LinkedHashMap while the Proxy class attempts to cast it to the object I specified (UserGroup.class)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!