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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content