users@jersey.java.net

[Jersey] Re: Jersey(2.10.4) Entity provider selection algorithm gives less priority to custom providers(MessageBodyWriter) making it not to be invoked

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Tue, 24 Feb 2015 17:38:23 +0100

A few questions/comments:

1. Why do you use a custom writer to serialize into XML??? JAX-RS ships with a JAXB writer that can do the serialization for you.
2. If you for some reason must use a custom writer, can you create a base abstract DTO class and inherit all your DTOs from it? Then you would be able to provide a writer for the abstract DTO and things should work.
3. If even that does not work, your use case should IMO still work and if it doesn’t, just try to declare your writer as “implements MessagebodyWriter<Object>” and see if it helps. (If it doesn’t, please file a bug.)

Cheers,
Marek


> On 23 Feb 2015, at 10:32, Shaswat <shaswat.dasgupta_at_gmail.com> wrote:
>
> Hi Mark,
>
> Thanks for the reply.
>
> Well My custom MBR looks like below
> @Provider
> @Produces("application/xml")
> public class RestDataSourceMessageBodyWriter implements MessageBodyWriter {
>
> if I make my custom MBR more specific like
>
> @Provider
> @Produces("application/xml")
> public class RestDataSourceMessageBodyWriter implements
> MessageBodyWriter<UserInfoDTO> {
>
> (Here "UserInfoDTO" is the first DTO object which gets searlized to xml by
> entity provider) *then it works* .But we cannot write custom MBR for
> thousands of DTOs and it has to be any ways.What do you suggest here?
>
>
>
>
>
> --
> View this message in context: http://jersey.576304.n2.nabble.com/Jersey-2-10-4-Entity-provider-selection-algorithm-gives-less-priority-to-custom-providers-MessageBodd-tp7583127p7583151.html
> Sent from the Jersey mailing list archive at Nabble.com.