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
- Match the requested type to the response Content-Type, or register a MessageBodyReader that supports the pair
- Add the missing serialization dependency (quarkus-rest-jackson / quarkus-rest-jaxb) or annotate the type for reflection (@RegisterForReflection)
- Fix @Consumes / Accept headers on the client method so the negotiated media type matches an available reader
- 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
- Check response.getMediaType() before readEntity with a POJO type
- Ensure Jackson/JSON-B (quarkus-rest-jackson etc.) is on the classpath
- Set @Consumes/Accept headers so negotiated media types match available readers
- Register POJOs with @RegisterForReflection for native-image deserialization
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
- Multipart field media type cannot be null
- mediaType must not be null
- Unable to deserialize the dev mode context. Does the Quarkus
- Could not deserialize the provided message.
- Don't know how to get event data (dataContentType: '%s', jav
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/6e1a3a82d1cd0462.
Report an issue: GitHub.