quarkusio/quarkus · error · NotSupportedException

Media type '" + mediaType + "' in multipart request is not s

Error message

Media type '" + mediaType + "' in multipart request is not supported

What it means

MultipartSupport.findReader throws a jakarta.ws.rs.NotSupportedException when reading an incoming multipart part because no MessageBodyReader is readable for the part's declared type and media type. The server cannot deserialize the part body into the target parameter type. This is the inbound (reader) counterpart to the writer lookup errors.

Source

Thrown at independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/multipart/MultipartSupport.java:148

        List<MessageBodyReader<?>> readers = serialisers.findReaders(null, type, mediaType, RuntimeType.SERVER);
        if (readers.isEmpty()) {
            throw new NotSupportedException();
        }

        for (MessageBodyReader<?> reader : readers) {
            if (reader instanceof ServerMessageBodyReader) {
                ServerMessageBodyReader<?> serverMessageBodyReader = (ServerMessageBodyReader<?>) reader;
                if (serverMessageBodyReader.isReadable(type, genericType, context.getTarget().getLazyMethod(), mediaType)) {
                    return serverMessageBodyReader;
                }
            } else {
                // TODO: should we be passing in the annotations?
                if (reader.isReadable(type, genericType, EMPTY_ANNOTATIONS, mediaType)) {
                    return reader;
                }
            }
        }
        throw new NotSupportedException("Media type '" + mediaType + "' in multipart request is not supported");
    }

    private static Object read(MessageBodyReader<?> reader, String attributeName, Supplier<InputStream> inputStreamSupplier,
            Class type, Type genericType, MediaType mediaType,
            ResteasyReactiveRequestContext context) {
        try {
            if (reader instanceof ServerMessageBodyReader) {
                ServerMessageBodyReader<?> serverMessageBodyReader = (ServerMessageBodyReader<?>) reader;
                // this should always be an empty stream as multipart doesn't set the request body
                InputStream originalInputStream = context.getInputStream();
                try {
                    // we need to set a fake input stream in order to trick the readers into thinking they are reading from the body
                    context.setInputStream(inputStreamSupplier.get());
                    return serverMessageBodyReader.readFrom(type, genericType, mediaType, context);
                } finally {
                    context.setInputStream(originalInputStream);
                }
            } else {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add quarkus-resteasy-reactive-jackson (or the appropriate reader extension) to the project.
  2. Set @PartType(MediaType.APPLICATION_JSON) on the input part field so the JSON reader is selected.
  3. Register a custom MessageBodyReader @Provider for the part type/media type.
  4. Change the parameter type to something readable (String, InputStream, FileUpload) and parse manually.

Example fix

// before
@RestForm MyPojo data; // no reader for text/plain -> MyPojo
// after
@RestForm
@PartType(MediaType.APPLICATION_JSON)
public MyPojo data;
Defensive patterns

Strategy: validation

Validate before calling

if (partType == null || partType.equals(MediaType.TEXT_PLAIN) && !String.class.equals(paramType)) { throw new ConfigurationException("unsupported part media type " + partType + " for " + paramType); }

Try / catch

try { return readPart(...); } catch (NotSupportedException e) { log.error("no reader for multipart part: " + e.getMessage()); throw new BadRequestException("unsupported part"); }

Prevention

When it happens

Trigger: A @RestForm / multipart input parameter has a type (e.g. a POJO) whose @PartType media type has no matching MessageBodyReader; missing JSON reader extension for a JSON part.

Common situations: Binding JSON parts to POJOs without quarkus-resteasy-reactive-jackson; custom part types with no reader; mismatched @PartType (e.g. text/plain for a POJO).

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/8c893def503cfced. Report an issue: GitHub.