In part 1 I described the ways in which the documented approach doesn’t work. This post is about my first workaround, but for a comprehensive debrief, see part 3.
The approach that works is:
- Build with the jersey-media-moxy module – so
- Put the jaxb.properties file in the right place – so
- Create a mapping file – so
- Create a ContextResolver – example. This will be used for JSON but not for XML.
- Create a MessageBodyWriter – example. This will be used for XML.
- Most importantly, write and let me know where on earth I went wrong to need to jump through all these hoops 🙂
Check out this little demo project to see how it all fits together.