[Rest-Dispatch] Cannot instantiate sub resource.

19 views
Skip to first unread message

Richard Wallis

unread,
May 11, 2015, 9:00:36 AM5/11/15
to gwt-pl...@googlegroups.com
During deserialization gwt-jackson throws an error: Can't instantiate ChanceResource.

I've copied the pattern from CarStore where CarsResource returns the subresource CarResource but must have missed something..


ChanceResource is an interface so obviously can't be instantiated but in CarStore CarResource is the same and works fine:

Here are the relevant jax-rs interfaces.  All the calls work fine on the server.

@Produces(MediaType.APPLICATION_JSON)
public interface BaseResource<T extends MPEntity<T>> {
   
   
@GET
   
List<T> getAll();
   
   
@GET
   
@Path(ApiPaths.ID)
    T
get(@PathParam(Param.ID) String id);
   
   
@GET
   
@Path("/" + Param.COUNT)
   
int count();
   
   
@POST
    T save
(T entity);
   
   
@DELETE
   
void delete(T entity);
   
}

@Path(ApiPaths.GAME)
@Produces(MediaType.APPLICATION_JSON)
public interface GameResource extends BaseResource<Game> {

   
@Path("/{" + Param.GAME_ID + "}" + ApiPaths.CHANCE)
   
@GET
   
ChanceResource getChanceResource(@PathParam(Param.GAME_ID) String gameId);
   
}

@Produces(MediaType.APPLICATION_JSON)
public interface ChanceResource extends BaseResource<Chance> {

}


Any suggestions?

Christopher Viel

unread,
May 11, 2015, 9:24:40 AM5/11/15
to gwt-pl...@googlegroups.com
Remove the @GET from the SubResource method:
    @Path("/{" + Param.GAME_ID + "}" + ApiPaths.CHANCE)
    ChanceResource getChanceResource(@PathParam(Param.GAME_ID) String gameId);

Rest Dispatch interprets actions end-points before sub resources and HTTP verbs are what is used to find those.

--
You received this message because you are subscribed to the Google Groups "GWTP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Wallis

unread,
May 11, 2015, 9:31:08 AM5/11/15
to gwt-pl...@googlegroups.com
Awesome that fixes it.  Thanks Chris
Reply all
Reply to author
Forward
0 new messages