users@jersey.java.net

[Jersey] Consuming media type conflict

From: <frederic.tardif_at_gmail.com>
Date: Wed, 28 Mar 2012 19:15:26 +0000 (GMT)

Hi,

I am trying to use jersey with a limit use case:

I need to implement a protocol (rfc lost) exposing messages in a
not-so-well-resouce-based-way....

The pitfall I am hitting is that all my api methods must be defined on
the same path (and produces/consumes the same media-type). The only
difference is the JaxB entity provided in the http request body.

here's a example of a broken service definition:
@Path("/")
@Singleton
public interface LostService {

  @POST
  @Consumes("application/lost+xml")
  @Produces("application/lost+xml")
  FindServiceResponse findService(FindService findServiceRequest) ;

  
  @POST
  @Consumes("application/lost+xml")
  @Produces("application/lost+xml")
  GetServiceBoundaryResponse getServiceBoundary(GetServiceBoundary
getServiceBoundaryRequest);

[...]
}

I understand my api is not in the REST mindset, but I was hoping that
jersey would have been able to trigger the right method based on the
entity type... Is there a trick someone could suggest to achieve this?

here is the error I am getting:
[2012/03/28 14:11:29.211]**SEVR [10] The following errors and warnings
have been detected with resource and/or provider classes:
  SEVERE: Consuming media type conflict. The resource methods public
abstract com.bell.cts.ng911.lost.beans.GetServiceBoundaryResponse
com.bell.cts.ng911.lost.LostService.getServiceBoundary(com.bell.cts.ng9
11.lost.beans.GetServiceBoundary) throws
com.bell.cts.ng911.lost.exceptions.LoSTException and public abstract
com.bell.cts.ng911.lost.beans.FindServiceResponse
com.bell.cts.ng911.lost.LostService.findService(com.bell.cts.ng911.lost
.beans.FindService) throws
com.bell.cts.ng911.lost.exceptions.LoSTException can consume the same
media type (processErrorMessages,
com.sun.jersey.spi.inject.Errors.java)