quarkusio/quarkus · error · ProcessingException

Response could not be mapped to type " + entityType + " for

Error message

Response could not be mapped to type " + entityType + " for response with media type " + mediaType

What it means

After walking all ReaderInterceptors and MessageBodyReaders, no reader could convert the response body into the requested Java type. ClientReaderInterceptorContextImpl.proceed() builds an error message including the target entityType and the response's media type (plus any reader hints collected in contextMessages) and throws ProcessingException, per the JAX-RS spec.

Source

Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientReaderInterceptorContextImpl.java:133

                    public MediaType mediaType() {
                        return mediaType;
                    }
                };
                List<String> contextMessages = new ArrayList<>(contextualizers.size());
                for (var contextualizer : contextualizers) {
                    String contextMessage = contextualizer.provideContextMessage(input);
                    if (contextMessage != null) {
                        contextMessages.add(contextMessage);
                    }
                }
                if (!contextMessages.isEmpty()) {
                    errorMessage.append(". Hints: ");
                    errorMessage.append(String.join(",", contextMessages));
                }
            }

            // Spec says to throw this
            throw new ProcessingException(errorMessage.toString());
        } else {
            return interceptors[index++].aroundReadFrom(this);
        }
    }

    @Override
    public InputStream getInputStream() {
        return inputStream;
    }

    @Override
    public void setInputStream(InputStream is) {
        this.inputStream = is;
    }

    @Override
    public MultivaluedMap<String, String> getHeaders() {
        return headers;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Match the requested type to the response Content-Type, or register a MessageBodyReader that supports the pair
  2. Add the missing serialization dependency (quarkus-rest-jackson / quarkus-rest-jaxb) or annotate the type for reflection (@RegisterForReflection)
  3. Fix @Consumes / Accept headers on the client method so the negotiated media type matches an available reader
  4. Read the full ProcessingException message — the appended Hints list names what the attempted readers reported; fix the root hint

Example fix

// before
String body = res.readEntity(MyDto.class); // media type text/plain

// after
if (res.getMediaType().isCompatible(MediaType.APPLICATION_JSON_TYPE)) {
    MyDto dto = res.readEntity(MyDto.class);
} else {
    String text = res.readEntity(String.class); // handle non-JSON body
}
Defensive patterns

Strategy: try-catch

Validate before calling

// check compatibility before reading
MediaType mt = response.getMediaType();
if (mt == null || !mt.isCompatible(MediaType.APPLICATION_JSON_TYPE)) {
    String raw = response.readEntity(String.class); // inspect body first
    throw new IllegalStateException("Unexpected content-type " + mt + ": " + raw);
}

Try / catch

try {
    return response.readEntity(MyDto.class);
} catch (ProcessingException e) {
    if (e.getMessage() != null && e.getMessage().contains("Response could not be mapped to type")) {
        // fall back to String and log the raw body + media type
        String raw = response.readEntity(String.class);
        throw new IllegalStateException("Cannot map " + response.getMediaType() + " body: " + raw, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling response.readEntity(SomeType.class) where no registered MessageBodyReader supports SomeType for the response's Content-Type — e.g. reading a text/plain response as a POJO, or a JSON response into a type without a matching reader/Jackson ObjectMapper config.

Common situations: Server returns a different Content-Type than expected (error pages as text/html); missing @Consumes on the client interface method; missing JSON-B/Jackson dependency or @RegisterForReflection for the target class; custom reader interceptors skipping the terminal reader.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/6e1a3a82d1cd0462. Report an issue: GitHub.