quarkusio/quarkus · error · IllegalArgumentException

Unsupported type: ${rawType.getName()}. Use InputStream, Str

Error message

Unsupported type: ${rawType.getName()}. Use InputStream, String, or byte[].

What it means

EntityPartImpl.readContent, invoked from the typed getContent overloads, throws IllegalArgumentException when no MessageBodyReader is readable for the requested raw type at the part's media type. The builtin fallbacks handle InputStream, String, and byte[]; anything else requires a registered reader for that media type. The message suggests those three types.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/EntityPartImpl.java:100

        if (rawType == InputStream.class) {
            return rawType.cast(content);
        }
        if (rawType == String.class) {
            return rawType.cast(new String(content.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8));
        }
        if (rawType == byte[].class) {
            return rawType.cast(content.readAllBytes());
        }
        if (serialisers != null) {
            List<MessageBodyReader<?>> readers = serialisers.findReaders(null, rawType, mediaType);
            for (MessageBodyReader<?> r : readers) {
                if (r.isReadable(rawType, genericType, EMPTY_ANNOTATIONS, mediaType)) {
                    MessageBodyReader<T> reader = (MessageBodyReader<T>) r;
                    return reader.readFrom(rawType, genericType, EMPTY_ANNOTATIONS, mediaType, headers, content);
                }
            }
        }
        throw new IllegalArgumentException(
                "Unsupported type: " + rawType.getName() + ". Use InputStream, String, or byte[].");
    }

    @Override
    public MultivaluedMap<String, String> getHeaders() {
        return headers;
    }

    @Override
    public MediaType getMediaType() {
        return mediaType;
    }

    public static boolean isEntityPartList(Type type) {
        if (type instanceof ParameterizedType pt) {
            if (pt.getRawType() == List.class) {
                Type[] args = pt.getActualTypeArguments();
                return args.length == 1 && args[0] == EntityPart.class;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use one of the guaranteed types — InputStream, String, or byte[] — and deserialize manually.
  2. Ensure a JSON provider (Jackson or JSON-B) is present and the part's media type is application/json so the reader can match.
  3. Check that the requested type is one the provider's isReadable accepts (e.g. a concrete bean, not Object or an unmapped interface).
  4. Register a custom MessageBodyReader for the type if it must be read directly.

Example fix

// before
MyPojo pojo = part.getContent(MyPojo.class); // no reader for media type
// after
String json = part.getContent(String.class);
MyPojo pojo = jsonb.fromJson(json, MyPojo.class);
Defensive patterns

Strategy: fallback

Validate before calling

// Verify a JSON provider exists for the target type before reading
// Safer: read as String and convert manually
String raw = part.getContent(String.class);
MyPojo pojo = jsonb.fromJson(raw, MyPojo.class);

Type guard

static boolean isDirectlyReadable(Class<?> rawType) {
    return InputStream.class.isAssignableFrom(rawType)
        || String.class.equals(rawType)
        || byte[].class.equals(rawType);
}

Try / catch

try {
    return part.getContent(MyPojo.class);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Unsupported type:")) {
        String json = part.getContent(String.class); // NOTE: only if content not yet consumed
        return jsonb.fromJson(json, MyPojo.class);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling part.getContent(MyCustomPojo.class) where the part's media type has no matching readable MessageBodyReader registered (no JSON provider for application/json, or a type the provider rejects via isReadable).

Common situations: Missing quarkus-resteasy-reactive-jackson or JSON-B provider on the classpath; requesting a POJO from a part whose media type is application/octet-stream; using an exotic type (Map without type info, custom container types) unsupported by the configured reader.

Related errors


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