{"record":{"id":"999e2bb26ba95a1b","repo":"quarkusio/quarkus","slug":"could-not-find-messagebodywriter-for-999e2b","errorCode":null,"errorMessage":"Could not find MessageBodyWriter for ","messagePattern":"Could not find MessageBodyWriter for ","errorType":"http","errorClass":"InternalServerErrorException","httpStatus":500,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/FixedEntityWriterArray.java","lineNumber":35,"sourceCode":"public class FixedEntityWriterArray implements EntityWriter {\n\n    private final MessageBodyWriter[] writers;\n    private final ServerSerialisers serialisers;\n\n    public FixedEntityWriterArray(MessageBodyWriter[] writers, ServerSerialisers serialisers) {\n        this.writers = writers;\n        this.serialisers = serialisers;\n    }\n\n    @Override\n    public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {\n        for (int i = 0; i < writers.length; ++i) {\n            MessageBodyWriter writer = writers[i];\n            if (ServerSerialisers.invokeWriter(context, entity, writer, serialisers)) {\n                return;\n            }\n        }\n        throw new InternalServerErrorException(\"Could not find MessageBodyWriter for \" + entity.getClass(),\n                Response.serverError().build());\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/FixedEntityWriterArray.java#L17-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n@GET @Produces({\"application/json\"})\npublic Object get() { return List.of(new Dto()); } // no writer matches\n// after\n@GET @Produces(MediaType.APPLICATION_JSON)\npublic List<Dto> get() { return List.of(new Dto()); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return invocation.invoke();\n} catch (InternalServerErrorException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Could not find MessageBodyWriter\")) {\n        throw new IllegalStateException(\"No writer in build-time candidate set for \" + entityClass, e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["resteasy-reactive","serialization","messagebodywriter","http-500"],"backgroundTag":"no-messagebodywriter-for-entity","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}