Exposing a JAXB Annotated POJO as JSON via CXF-RS

Solution Verified - Updated -

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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.