{"record":{"id":"e4d13e1c5975b1f1","repo":"quarkusio/quarkus","slug":"could-not-find-messagebodywriter-for-e4d13e","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/FixedEntityWriter.java","lineNumber":29,"sourceCode":"\n/**\n * A fixed entity writer that can be used when we know the result will always be written\n * by a given provider.\n */\npublic class FixedEntityWriter implements EntityWriter {\n\n    private final MessageBodyWriter writer;\n    private final ServerSerialisers serialisers;\n\n    public FixedEntityWriter(MessageBodyWriter writer, ServerSerialisers serialisers) {\n        this.writer = writer;\n        this.serialisers = serialisers;\n    }\n\n    @Override\n    public void write(ResteasyReactiveRequestContext context, Object entity) throws IOException {\n        if (!ServerSerialisers.invokeWriter(context, entity, writer, serialisers)) {\n            throw new InternalServerErrorException(\"Could not find MessageBodyWriter for \" + entity.getClass(),\n                    Response.serverError().build());\n        }\n    }\n\n}\n","sourceCodeStart":11,"sourceCodeEnd":35,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/serialization/FixedEntityWriter.java#L11-L35","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\n@Produces(MediaType.TEXT_PLAIN)\npublic MyDto get() { ... } // plain-text String writer can't handle MyDto\n// after\n@Produces(MediaType.APPLICATION_JSON)\npublic MyDto get() { ... }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return resource.call();\n} catch (InternalServerErrorException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Could not find MessageBodyWriter\")) {\n        // fall back to explicit JSON serialization\n        return Response.ok(jsonOf(entity)).type(MediaType.APPLICATION_JSON).build();\n    }\n    throw e;\n}","preventionTips":["Rebuild after changing return types (stale build-time wiring).","Match @Produces to the actual writer capabilities.","Test custom MessageBodyWriter.isWriteable against runtime subclasses."],"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"}