Same issue when moving @PUT to the abstract class:

   @javax.ws.rs.PUT
   @javax.ws.rs.Path("/{id}")
public void update(@javax.ws.rs.PathParam("id") long id, User user) { ... }


Tom wrote:
Hey Sergey,

I do not know what the reason is, all I know is that if I have:

   @POST public void add(User user) {...}

In the regular class, it works, but if I move the code to the abstract class and make it generic, like so:

   @POST public void add(T user) {...}

then I get the exception. But it works ok for @GET list(), or @GET find(long id).

Tom

PS: Please note my typo in the initial post that the abstract class does not know "User" but only the generic "T".




Sergey Beryozkin wrote:
Hi,

So just to confirm, for the purpose of writing a test,

@Path(...)
@Produces(...)
UserServiceImpl extends AbstractServiceImpl<User>
implements UserService
{
}


abstract class AbstractServiceImpl<T> {
{
   @POST
   public void add(User user) {...// reflection ...//}
}

can not be matched with 'User' add parameter being confused for Object ?
If no then please correct me...
I'll do a test shortly

Cheers, Sergey




----- Original Message ----- From: "Tom" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 14, 2009 10:52 AM
Subject: Inheriting methods


I have to implement basic CRUD operations on a serious number of Entities. The to-be-executed code is identical for all classes, except that different DAO implementating classes are involved. So I decided to go for reflection, so instead of:

/@Path(...)
@Produces(...)
implements UserService
UserServiceImpl
{
   @GET
   public void list() {... same code over and over again... }

   @POST
public void add(User user) {... //same code over and over again... //}
}
/

I have


/@Path(...)
@Produces(...)
UserServiceImpl extends AbstractServiceImpl<User>
implements UserService
{
}


abstract AbstractServiceImpl<T>
{
   @GET
   public void list() {... reflection ...}

   @POST
   public void add(User user) {...// reflection ...//}
}
/

This works fine for REST-GET but not for REST-POST, there I get a "No message body reader found for request class : Object, ContentType : text/xml". This most definitely has to do with the resolving of the @POST, because if I add the code below the the UserServiceImpl, then it all works ok.

/    @POST public void add(User user) { super.add(user); }

/Any suggestions on why?

Tom








Reply via email to