-
Bug
-
Resolution: Done
-
Critical
-
3.6.2.Final
-
None
-
None
When trying to use the JSON-B provider (aka json-binding) with a BV related example, I discovered it does not play well with the Bean Validation support:
Caused by: org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: org.jboss.resteasy.api.validation.ViolationReport of media type: application/json
at org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$2(ServerResponseWriter.java:105)
at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:405)
at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:218)
The issue here is that ViolationReport has some JAXB annotations (as we also need it to work with XML) and, in this case, the JSON-B provider is not considered as valid:
https://github.com/resteasy/Resteasy/blob/3.6/providers/json-binding/src/main/java/org/jboss/resteasy/plugins/providers/jsonb/JsonBindingProvider.java#L68
I don't think these JAXB conditions is a good idea for 2 reasons:
- having JAXB annotations don't say you won't use JSON to serialize the object;
- JAXB is gone in stock JDK 11 and the JsonBindingProvider won't work if JAXB is not in the classpath. So you would need to add a JAXB API jar to your classpath to have JSON-B working, which sounds like a bad idea.
I think we should get rid of these JAXB conditions (and of the condition on the presence of JSON-B annotations as they are not required and it won't make sense anymore).
- is cloned by
-
RESTEASY-2158 Unable to use Bean Validation with JSON-B in RESTEasy 3.x
- Open
- is related to
-
RESTEASY-1316 Deprecate/remove Jettison for Jackson
- Resolved
- relates to
-
RESTEASY-2108 Make JsonBindingProvider more restrictive (@Consumes/@Provides media types)
- Resolved