Exposing a JAXB Annotated POJO as JSON via CXF-RS
Issue
- Have a JAXB annotated POJO request / response that is used in a CXF WS and try to expose this as a JSON REST service;
- When sending a JSON request, get the following error response:
JSON request:
{
"xxxRequest": {
"header": {
...
},
"data": {
...
}
}
}
Error:
JAXBException occurred : unexpected element (uri:"", local:"xxxRequest"). Expected elements are
<{http://www.companyname.com/aaa/bbb/ccc/v1}...>,
<{http://www.companyname.com/aaa/bbb/ccc/v1}...>,
<{http://www.companyname.com/aaa/bbb/ccc/v1}xxxRequest>,
<{http://www.companyname.com/aaa/bbb/ccc/v1}...>.
Environment
- Red Hat JBoss Fuse 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.