Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jerseyrobot opened this issue Sep 16, 2015 · 6 comments

Comments

@jerseyrobot
Copy link
Contributor

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]

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
Reported by Miko95

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
@mpotociar said:
Looks like MOXy entity providers should be registered with lower priority to not interfere with application-specific custom providers.

@jerseyrobot
Copy link
Contributor Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JERSEY-2963

@jerseyrobot
Copy link
Contributor Author

@saratbhaswanth
Copy link

+1

Configured Moxy and started facing issue for Long Object response. Is any fix available?

@saratbhaswanth
Copy link

+1

Configured Moxy and started facing issue for Long Object response. Is any fix available?

Issue solved for me when using proper @produces annotation.

In this case, it used to be @produces(MediaType.APPLICATION_JSON). Changing it to @produces(MediaType.TEXT_PLAIN) solved the issue.

Since the output is Long, it is going through BasicTypesMessageProvider writer model which serializes only for "text/plain".

@Produces({"text/plain"})
@Consumes({"text/plain"})
@Singleton
final class BasicTypesMessageProvider extends AbstractMessageReaderWriterProvider<Object> {...}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants