quarkusio/quarkus · error · ProcessingException

Request could not be mapped to type ${genericType != null ?

Error message

Request could not be mapped to type ${genericType != null ? genericType : entityType}

What it means

RestResponseImpl.readEntity throws this ProcessingException when the response cannot produce an entity of the requested type. Per the JAX-RS spec, if no entity is present (or the existing entity is not an instance of the requested type) and no suitable MessageBodyReader can map the raw stream to the target type, the request 'could not be mapped'. The message shows the generic type or class that was requested.

Source

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

    }

    public InputStream getEntityStream() {
        return entityStream;
    }

    public void setEntityStream(InputStream entityStream) {
        this.entityStream = entityStream;
    }

    protected <T> T readEntity(Class<T> entityType, Type genericType, Annotation[] annotations) {
        // TODO: we probably need better state handling
        if (entity != null && entityType.isInstance(entity)) {
            // Note that this works if entityType is InputStream where we return it without closing it, as per spec
            return (T) entity;
        }
        checkClosed();
        // Spec says to throw this
        throw new ProcessingException(
                "Request could not be mapped to type " + (genericType != null ? genericType : entityType));
    }

    @Override
    public <OtherT> OtherT readEntity(Class<OtherT> entityType) {
        return readEntity(entityType, entityType, null);
    }

    @SuppressWarnings("unchecked")
    @Override
    public <OtherT> OtherT readEntity(GenericType<OtherT> entityType) {
        return (OtherT) readEntity(entityType.getRawType(), entityType.getType(), null);
    }

    @Override
    public <OtherT> OtherT readEntity(Class<OtherT> entityType, Annotation[] annotations) {
        return readEntity(entityType, entityType, annotations);
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify a JSON binding provider (quarkus-rest-jackson or quarkus-rest-jsonb) is a dependency so a MessageBodyReader exists for your type
  2. Check response.hasEntity() / status before calling readEntity; handle 204/empty bodies
  3. Call bufferEntity() before reading if you need to read the entity more than once
  4. Ensure readEntity is called with the correct type matching the actual response content-type

Example fix

// before
Foo foo = response.readEntity(Foo.class); // ProcessingException if no reader
// after
if (response.getStatus() == 204 || !response.hasEntity()) {
    return null;
}
Foo foo = response.bufferEntity().readEntity(Foo.class);
Defensive patterns

Strategy: validation

Validate before calling

if (response == null || response.getStatusInfo().family == Family.CLIENT_ERROR || response.getStatusInfo().family == Family.SERVER_ERROR || !response.hasEntity()) {
    return fallback();
}

Type guard

boolean isReadable(RestResponse<?> r, Class<?> type) {
    return r != null && !r.isClosed() && r.hasEntity() && r.getMediaType() != null;
}

Try / catch

try {
    return response.readEntity(Foo.class);
} catch (ProcessingException e) {
    log.error("Entity not mappable to Foo: " + e.getMessage());
    return fallback();
}

Prevention

When it happens

Trigger: Calling readEntity(Foo.class) on a response that (a) was closed, (b) has no entity, or (c) whose entity stream cannot be converted to Foo because no MessageBodyReader is registered for that type/media-type combination.

Common situations: Reading a JSON response into a POJO when the REST client Reactive JSON-B/Jackson mapper is not on the classpath; calling readEntity twice without buffering; reading entity after close(); expecting an entity on a 204 No Content response.

Related errors


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