users@jersey.java.net

[Jersey] Re: Consuming media type conflict

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Thu, 29 Mar 2012 10:18:07 +0200

Hello Frederic,

you can't select resource method by entity java type.

Jersey/JAX-RS is not suitable for your usecase (just confirming what you
already know) and your service is simple enough to implement it as
custom servlet - you don't really need Jersey and you are not using
basically any features that JAX-RS provides.

Regards,
Pavel

On 3/28/12 9:15 PM, frederic.tardif_at_gmail.com wrote:
> 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)
>