quarkusio/quarkus · error · InternalServerErrorException
Could not find MessageBodyWriter for
Error message
Could not find MessageBodyWriter for
What it means
Runtime serialization failure in FixedEntityWriterArray.write: none of the pre-selected MessageBodyWriter instances for the fixed writer array can write the response entity's Java type/media type combination. The entity class that failed to find a writer follows the message; typically a missing writer dependency (e.g. no REST Jackson for the type) or an unserializable return type on the endpoint.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/FixedEntityWriterArray.java:35
public class FixedEntityWriterArray implements EntityWriter {
private final MessageBodyWriter[] writers;
private final ServerSerialisers serialisers;
public FixedEntityWriterArray(MessageBodyWriter[] writers, ServerSerialisers serialisers) {
this.writers = writers;
this.serialisers = serialisers;
}
@Override
public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {
for (int i = 0; i < writers.length; ++i) {
MessageBodyWriter writer = writers[i];
if (ServerSerialisers.invokeWriter(context, entity, writer, serialisers)) {
return;
}
}
throw new InternalServerErrorException("Could not find MessageBodyWriter for " + entity.getClass(),
Response.serverError().build());
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Add quarkus-rest-jackson/quarkus-rest-jsonb so a JSON writer is in the candidate set.
- Narrow or correct the declared return type so build-time selection includes the right writer.
- Verify @Produces media types match a registered writer for the entity.
- Annotate the entity with @RegisterForReflection and rebuild (needed for native).
Example fix
// before
@GET @Produces({"application/json"})
public Object get() { return List.of(new Dto()); } // no writer matches
// after
@GET @Produces(MediaType.APPLICATION_JSON)
public List<Dto> get() { return List.of(new Dto()); } Defensive patterns
Strategy: try-catch
Try / catch
try {
return invocation.invoke();
} catch (InternalServerErrorException e) {
if (e.getMessage() != null && e.getMessage().contains("Could not find MessageBodyWriter")) {
throw new IllegalStateException("No writer in build-time candidate set for " + entityClass, e);
}
throw e;
} Prevention
- Restrict return types to the set covered by @Produces-declared writers.
- Install the JSON extension so the candidate array always contains a POJO writer.
- Exercise every endpoint in CI to catch uncovered types.
When it happens
Trigger: A resource with multiple possible return/produces combinations (e.g. @Produces({JSON, TEXT})) returns an entity class that none of the preselected writers can handle.
Common situations: Returning a type outside the set anticipated at build time (Object, exotic collections); missing JSON extension so no writer in the array handles POJOs; runtime class differs from declared type.
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/999e2bb26ba95a1b.
Report an issue: GitHub.