Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF: WARNING: No message body writer has been found for response class ArrayList

Tags:

cxf

I'm getting the following error:

WARNING: No message body writer has been found for response class ArrayList.

On the following code:

    @GET
    @Consumes("application/json")
    public List getBridges() {
        return  new ArrayList(bridges);
    }

I know it's possible for CXF to handle this case because I've done it before - with a platform that defined the CXF and related maven artifacts behind the scenes (i.e. I didn't know how it was done).

So, the question: how can I get CXF to support this without adding XML bindings or other source code modifications?

Note the following answer addressed the same problem with XML bindings, which is not satisfactory for my case: No message body writer has been found for response class ArrayList

like image 950
ash Avatar asked Apr 20 '14 01:04

ash


1 Answers

The problem turns out to be a simple missing Accept header:

Accept: application/json

Adding this to the request resolves the problem.

like image 57
ash Avatar answered Sep 21 '22 12:09

ash