quarkusio/quarkus · error · InternalServerErrorException
Could not find MessageBodyWriter for
Error message
Could not find MessageBodyWriter for
What it means
TypeDelegatingEntityWriter walks the entity's class hierarchy looking for a delegate MessageBodyWriter registered for that class (or a superclass). If no writer is registered anywhere up the hierarchy, an InternalServerErrorException (500) is thrown.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/TypeDelegatingEntityWriter.java:34
private final Map<Class<?>, EntityWriter> typeMap;
public TypeDelegatingEntityWriter(Map<Class<?>, EntityWriter> typeMap) {
this.typeMap = typeMap;
}
@Override
public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {
Class<?> c = entity.getClass();
while (c != null) {
EntityWriter delegate = typeMap.get(c);
if (delegate != null) {
delegate.write(context, entity);
return;
}
c = c.getSuperclass();
}
throw new InternalServerErrorException("Could not find MessageBodyWriter for " + entity.getClass(),
Response.serverError().build());
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Add the JSON serialization extension (quarkus-rest-jackson or quarkus-rest-jsonb).
- Return the concrete type so build-time wiring selects a writer for it.
- For native builds add @RegisterForReflection to the entity (and relevant superclasses).
- Register a custom MessageBodyWriter or a serializer mapper for the third-party class.
Example fix
// before
@GET
public Object get() { return new ThirdPartyDto(); }
// after
@RegisterForReflection
@GET @Produces(MediaType.APPLICATION_JSON)
public ThirdPartyDto get() { return new ThirdPartyDto(); } Defensive patterns
Strategy: try-catch
Try / catch
try {
return target.request().get(MyDto.class);
} catch (InternalServerErrorException e) {
if (e.getMessage() != null && e.getMessage().contains("Could not find MessageBodyWriter")) {
log.errorf("No writer registered in type hierarchy of %s", MyDto.class);
}
throw e;
} Prevention
- Add @RegisterForReflection on entity classes and their superclasses for native.
- Prefer concrete return types so the type map is populated at build time.
- Register custom writers for third-party entity classes.
When it happens
Trigger: Returning an entity whose class (and all superclasses) has no writer registered in the runtime type map — typically a plain POJO with no JSON serializer or no @RegisterForReflection-based registration when the declared return type was Object/dynamic.
Common situations: Missing quarkus-rest-jackson/quarkus-rest-jsonb dependency; entity class not registered for reflection in native mode; returning a third-party class the app never registered a writer for.
Related errors
- Could not find MessageBodyWriter for
- Could not find MessageBodyWriter for
- Could not find MessageBodyWriter for
- Failed to serialize content of type
- Could not find MessageBodyWriter for ${entityClass}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/31c2d4e238acd715.
Report an issue: GitHub.