Personally i would extend johnzon provider and specify the produces type
you use. Or just register JohnzonMessageBodyWriter - provided in tomee libs
which handles more than just application/json bit not wildcard.

If you dont like importing johnzon you can implement a MessageBodyWriter
getting injected Providers and just delegating the calls switching
MediaType to json - think to say you dont handle json yourself to avoid
loops. This is then a portable solution.
Le 24 févr. 2016 13:22, "ravi" <[email protected]> a écrit :

> Hi Romain,
>
> How can I make the below code work in Tomee 7.0.0-M2
>
> I am getting the below error
> SEVERE - No message body writer has been found for class
> com.airhacks.HelloResource$Hello, ContentType:
> application/vnd.compnay.myapp.version1+json
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
>
> @Path("/")
> public class HelloResource {
>
>         @GET
>         @Path("hello")
>         @Produces("application/vnd.compnay.myapp.version1+json")
>         public Hello sayHello() {
>                 Hello hello = new Hello();
>                 hello.setName("HelloWorld!!!");
>                 return hello;
>         }
>
>         public class Hello {
>                 private String name;
>
>                 public String getName() {
>                         return name;
>                 }
>
>                 public void setName(String name) {
>                         this.name = name;
>                 }
>
>         }
> }
>
> Above code is working in tomee 7.0.0-M1.
>
> Need your help it is mandatory to use vendor specific content type for rest
> api versioning as per our company guidelines.
>
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomee-7-0-0-M2-JaxRs-Client-No-message-body-reader-has-been-found-for-class-ContentType-application-n-tp4677664p4677671.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Reply via email to