quarkusio/quarkus · error · InternalServerErrorException
Could not find MessageBodyWriter for
Error message
Could not find MessageBodyWriter for
What it means
MediaTypeDelegatingEntityWriter picks a delegate writer keyed by the response media type at runtime. If the negotiated response media type has no entry in the type map, no writer can be chosen and an InternalServerErrorException (500) is thrown.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/MediaTypeDelegatingEntityWriter.java:31
* An entity writer that will delegate based on the actual type of the
* returned entity.
*/
public class MediaTypeDelegatingEntityWriter implements EntityWriter {
private final Map<MediaType, EntityWriter> typeMap;
public MediaTypeDelegatingEntityWriter(Map<MediaType, EntityWriter> typeMap) {
this.typeMap = typeMap;
}
@Override
public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {
EntityWriter delegate = typeMap.get(context.getResponseMediaType());
if (delegate != null) {
delegate.write(context, entity);
return;
}
throw new InternalServerErrorException("Could not find MessageBodyWriter for " + entity.getClass(),
Response.serverError().build());
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Install a writer for the requested media type (e.g. add quarkus-rest-jackson for application/json, quarkus-rest-easy-... jaxb for xml).
- Fix the client's Accept header to one of the @Produces types the endpoint supports.
- Adjust the endpoint's @Produces to match an available writer.
- Verify with a single explicit Accept header in tests to see which media types actually resolve.
Example fix
// before // client curl -H 'Accept: application/xml' /endpoint // only JSON writer installed // after curl -H 'Accept: application/json' /endpoint
Defensive patterns
Strategy: validation
Validate before calling
// pre-check: only send Accept types the endpoint @Produces
Set<String> supported = Set.of("application/json", "text/plain");
if (!supported.contains(requestedAccept)) {
requestedAccept = "application/json"; // or send Accept: */*
} Prevention
- Align client Accept headers with endpoint @Produces.
- Send 'Accept: */*' when media type doesn't matter.
- Install writer extensions for every media type you advertise.
When it happens
Trigger: The response media type resolved for the request (from Accept negotiation or @Produces) is not one of the media types the build-time selected writers support, e.g. client Accepts application/xml but only a JSON writer was wired.
Common situations: Client requesting a media type the endpoint doesn't truly support while no 406 path applies; wildcard or unusual media types in Accept; @Produces set mismatched with installed serializer extensions.
Related errors
- Could not find MessageBodyWriter for
- Could not find MessageBodyWriter for
- Could not find MessageBodyWriter for
- Could not find MessageBodyWriter for
- Unknown JSON Value
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/601939411e3a0c6e.
Report an issue: GitHub.