简体   繁体   中英

MessageBodyWriter not found for media type application/json

I'm getting the following error in my logs:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
Grave: MessageBodyWriter not found for media type=application/json, type=class com.sample.MyDTO, genericType=class com.sample.MyDTO.

In general, it is caused by the lack of registered MessageBodyWriter but in my case, I do have the jersey-media-proxy JAR on the classpath (with all its dependencies). If that helps debugging, I confirm that the configure method of the MoxyJsonFeature is called when my web application is deployed.

I precise I'm using Jersey v2.21. My web application is deployed on Tomcat 8.0.26.

Any idea?

Thanks, Mickael

It took me a while to figure it out, but you let me to the solution. It appears that for Moxy to work you need use a:

  1. Default constructor
  2. Setter methods

for every resource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM