FasterXML/jackson-databind · error · UnsupportedOperationException

Only support `JavaType` implementation of `ResolvedType`, no

Error message

Only support `JavaType` implementation of `ResolvedType`, not: {}

What it means

DeserializationContext.readValue(JsonParser, ResolvedType) only knows how to handle a ResolvedType that is actually a JavaType (jackson-databind's own type representation). If a caller passes any other ResolvedType implementation, Jackson throws UnsupportedOperationException naming the offending class. In normal Jackson usage this is effectively unreachable because all internal code uses JavaType; it surfaces only when application code constructs a custom ResolvedType and hands it in.

Source

Thrown at src/main/java/tools/jackson/databind/DeserializationContext.java:393

     * rather use {@link #readPropertyValue(JsonParser, BeanProperty, Class)};
     * this method does not allow use of contextual annotations.
     */
    @Override
    public <T> T readValue(JsonParser p, Class<T> type) throws JacksonException {
        return readValue(p, getTypeFactory().constructType(type));
    }

    @Override
    public <T> T readValue(JsonParser p, TypeReference<T> refType) throws JacksonException {
        return readValue(p, getTypeFactory().constructType(refType));
    }

    @Override
    public <T> T readValue(JsonParser p, ResolvedType type) throws JacksonException {
        if (type instanceof JavaType jt) {
            return readValue(p, jt);
        }
        throw new UnsupportedOperationException(
                "Only support `JavaType` implementation of `ResolvedType`, not: "+type.getClass().getName());
    }

    @SuppressWarnings("unchecked")
    public <T> T readValue(JsonParser p, JavaType type) throws JacksonException {
        ValueDeserializer<Object> deser = findRootValueDeserializer(type);
        if (deser == null) {
            reportBadDefinition(type,
                    "Could not find `ValueDeserializer` for type "+ClassUtil.getTypeDescription(type));
        }
        return (T) _readValue(p, deser);
    }

    /**
     * Helper method that should handle special cases for deserialization; most
     * notably handling {@code null} (and possibly absent values).
     */
    private Object _readValue(JsonParser p, ValueDeserializer<Object> deser) throws JacksonException

View on GitHub (pinned to a50c7d2a1d)

Solutions

  1. Convert the ResolvedType to a JavaType first: use mapper.constructType(resolvedType) or typeFactory.constructType(...) before calling readValue.
  2. If you only have a java.lang.reflect.Type or a TypeReference, construct a JavaType from that instead.
  3. Avoid parameterizing your own helpers on ResolvedType; use JavaType throughout for databind operations.
  4. If a custom ResolvedType subclass is truly needed, subclass JavaType instead so it passes the instanceof check.

Example fix

// before
ResolvedType rt = ...; // some non-JavaType ResolvedType
Object v = ctxt.readValue(p, rt);
// after
JavaType jt = mapper.getTypeFactory().constructType(rt);
Object v = ctxt.readValue(p, jt);
Defensive patterns

Strategy: type-guard

Validate before calling

// Always convert ResolvedType to JavaType before readValue
JavaType jt = (type instanceof JavaType)
    ? (JavaType) type
    : mapper.getTypeFactory().constructType(type);
ctxt.readValue(parser, jt);

Type guard

boolean isJavaType(ResolvedType t) { return t instanceof JavaType; }

Prevention

When it happens

Trigger: Calling ctxt.readValue(parser, someResolvedType) where someResolvedType is a third-party ResolvedType (e.g. from another Jackson family member or a hand-rolled impl) rather than a JavaType obtained from TypeFactory. Also seen when generic helper code is parameterized on ResolvedType and forwards a value of an unexpected concrete subtype.

Common situations: Writing framework code that abstracts over ResolvedType across multiple Jackson dataformats/cores; passing a value obtained from a non-databind API (e.g. a streaming-layer type token) directly into a databind readValue; version skew where a ResolvedType subclass existed in an older setup but not the JavaType expected here.

Related errors


AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06). Data as JSON: /api/errors/f6054df09cdc08c6. Report an issue: GitHub.