eclipse-ee4j / eclipse-ee4j/jersey
Please don't catch JAXBContext createion exceptions in MOXyJsonProvider
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
when trying to use JAXB annotated classes with the moxy json provider in jersey a call will finally be made to
org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.getJAXBContext(Set>, Annotation[], MediaType, MultivaluedMap)
from isWriteable().
when something is wrong with the annotated classes the exception is eaten up here:
private JAXBContext getJAXBContext(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
if(null == genericType)
{ genericType = type; }
try
{ Set> domainClasses = getDomainClasses(genericType); return getJAXBContext(domainClasses, annotations, mediaType, null); }
catch(JAXBException e)
{ return null; // exception is eaten up! }
}
This results in an log message like:
"MessageBodyWriter not found for media type=application/json for.."
but the origianl exception was:
"Exception [EclipseLink-50013] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The property or field xyz on the class com.corporatename.class is required to be included in the propOrder element of the XmlType annotation."
it's really hard to debug JAXB problems when usinig Jersey as JAX-RS provider due to the removal of the exception.
Contributor guide
Assessment
This issue has not been assessed yet.