quarkusio/quarkus · error · IllegalArgumentException

Primitive types are not supported for multipart response…

Error message

Primitive types are not supported for multipart response mapping. Please use a wrapper class instead

What it means

Multipart response field fillers are generated via bytecode that wraps the declared type in a GenericType. Primitive kinds (int, boolean, etc.) cannot be loaded as a class via loadClassFromTCCL in this path, so the generator rejects them and asks for the wrapper class (Integer, Boolean, ...).

Solutions

  1. Change the field type to its wrapper class (int -> Integer, boolean -> Boolean, long -> Long, etc.)
  2. Rebuild; if the field is used with @PartType, keep the annotation on the wrapper field

Example fix

// before
class MultipartBody {
    @PartType("text/plain")
    public int count;
}
// after
class MultipartBody {
    @PartType("text/plain")
    public Integer count;
}
Defensive patterns

Strategy: validation

Validate before calling

for (var f : MultipartBody.class.getDeclaredFields()) { if (f.getType().isPrimitive()) throw new IllegalStateException("Use wrapper type for multipart field: " + f.getName()); }

Type guard

boolean isWrapperUsable(Class<?> c) { return !c.isPrimitive() && (c == Integer.class || c == Long.class || c == Boolean.class || c == Double.class || c == Float.class || c == Short.class || c == Byte.class || c == Character.class || !c.getSimpleName().isEmpty()); }

Try / catch

try { client.upload(body); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Primitive types")) { log.error("Change primitive field to wrapper class"); } throw e; }

Prevention

When it happens

Trigger: Declaring a multipart REST client response field of primitive type (e.g. int count, boolean active) in the class mapped from a multipart response, triggering the FieldFiller generation at build time.

Common situations: Writing DTOs with primitive fields by habit; JSON examples implying primitives; migrating a non-multipart DTO to multipart use without adjusting field types.

Related errors


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

Appendix: source

Thrown at extensions/resteasy-reactive/rest-client-jaxrs/deployment/src/main/java/io/quarkus/jaxrs/client/reactive/deployment/JaxrsClientReactiveProcessor.java:701

    }

    private void createFieldFillerConstructor(AnnotationInstance partType, Type type, String partName,
            String fillerClassName, ClassCreator c) {
        MethodCreator ctor = c.getMethodCreator(MethodDescriptor.ofConstructor(fillerClassName));

        ResultHandle genericType;
        if (type.kind() == PARAMETERIZED_TYPE) {
            genericType = createGenericTypeFromParameterizedType(ctor, type.asParameterizedType());
        } else if (type.kind() == CLASS) {
            genericType = ctor.newInstance(
                    MethodDescriptor.ofConstructor(GenericType.class, java.lang.reflect.Type.class),
                    ctor.loadClassFromTCCL(type.asClassType().name().toString()));
        } else if (type.kind() == ARRAY) {
            genericType = ctor.newInstance(
                    MethodDescriptor.ofConstructor(GenericType.class, java.lang.reflect.Type.class),
                    ctor.loadClassFromTCCL(type.asArrayType().name().toString()));
        } else if (type.kind() == PRIMITIVE) {
            throw new IllegalArgumentException("Primitive types are not supported for multipart response mapping. " +
                    "Please use a wrapper class instead");
        } else {
            throw new IllegalArgumentException("Unsupported field type for multipart response mapping: " +
                    type + ". Only classes, arrays and parameterized types are supported");
        }

        ctor.invokeSpecialMethod(
                MethodDescriptor.ofConstructor(FieldFiller.class, GenericType.class, String.class, String.class),
                ctor.getThis(), genericType, ctor.load(partName), ctor.load(partType.value().asString()));
        ctor.returnValue(null);
    }

    private AnnotationInstance partTypeFromGetterOrSetter(MethodInfo setter) {
        AnnotationInstance partTypeAnno = setter.annotation(PART_TYPE_NAME);
        if (partTypeAnno != null) {
            return partTypeAnno;
        }

View on GitHub (pinned to e1c734241f)