quarkusio/quarkus · error · InternalServerErrorException
Could not find MessageBodyWriter for
Error message
Could not find MessageBodyWriter for
What it means
FixedEntityWriter wraps a single MessageBodyWriter chosen at build time. If ServerSerialisers.invokeWriter reports that the writer cannot (or is not applicable to) write the entity, an InternalServerErrorException (500) is thrown.
Source
Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/FixedEntityWriter.java:29
/**
* A fixed entity writer that can be used when we know the result will always be written
* by a given provider.
*/
public class FixedEntityWriter implements EntityWriter {
private final MessageBodyWriter writer;
private final ServerSerialisers serialisers;
public FixedEntityWriter(MessageBodyWriter writer, ServerSerialisers serialisers) {
this.writer = writer;
this.serialisers = serialisers;
}
@Override
public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {
if (!ServerSerialisers.invokeWriter(context, entity, writer, serialisers)) {
throw new InternalServerErrorException("Could not find MessageBodyWriter for " + entity.getClass(),
Response.serverError().build());
}
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Rebuild the application (mvn clean install) so build-time writer selection matches the current code.
- Align the method's declared return type and @Produces with the actual entity being returned.
- Ensure custom MessageBodyWriter.isWriteable accepts the runtime entity class.
- Register the entity type explicitly with the writer/serializer configuration.
Example fix
// before
@Produces(MediaType.TEXT_PLAIN)
public MyDto get() { ... } // plain-text String writer can't handle MyDto
// after
@Produces(MediaType.APPLICATION_JSON)
public MyDto get() { ... } Defensive patterns
Strategy: try-catch
Try / catch
try {
return resource.call();
} catch (InternalServerErrorException e) {
if (e.getMessage() != null && e.getMessage().contains("Could not find MessageBodyWriter")) {
// fall back to explicit JSON serialization
return Response.ok(jsonOf(entity)).type(MediaType.APPLICATION_JSON).build();
}
throw e;
} Prevention
- Rebuild after changing return types (stale build-time wiring).
- Match @Produces to the actual writer capabilities.
- Test custom MessageBodyWriter.isWriteable against runtime subclasses.
When it happens
Trigger: A resource whose return type was mapped to a fixed writer at build time returns an entity that the writer's isWriteable rejects at runtime (mismatched generic type, changed entity class, null vs non-null media type mismatch).
Common situations: Return type changed after compilation (stale build); entity subclass not handled by the selected writer; application produced a media type the fixed writer doesn't support.
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/e4d13e1c5975b1f1.
Report an issue: GitHub.