eclipse-ee4j / eclipse-ee4j/jersey

MessageBodyWriter not found for media type application/json when using MOXy

Open
#3,235 6 comments 0 reactions 0 assignees View on GitHub
Component: media Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

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.

Also, I tried switching to Jackson and it works fine so I assume something is going wrong with MOXy.
#### Affected Versions
[2.21]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the application/json response with com.sample.MyDTO on Jersey 2.21 and verify the jersey-media-proxy dependency and MoxyJsonFeature.configure path. Compare the MOXy setup with the working Jackson setup. Done means a MessageBodyWriter is selected for MyDTO without changing the application to Jackson.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.