FasterXML/jackson-databind · error · UnsupportedOperationException
Cannot call withValueDeserializer() on {}
Error message
Cannot call withValueDeserializer() on {} What it means
Thrown when withValueDeserializer() is called on a JsonNodeParameterAnyProperty instance. This subclass (used for @JsonAnySetter on a creator parameter that targets a JsonNode/ObjectNode) deliberately throws UnsupportedOperationException because it cannot meaningfully accept a different value deserializer — the node-based any-setter serializes raw JsonNode content and does not delegate to a ValueDeserializer. The base class marks this as 'Should not get called but...' indicating it is a defensive guard against framework misuse.
Source
Thrown at src/main/java/tools/jackson/databind/deser/SettableAnyProperty.java:526
// Let's override since this is much simpler with JsonNodes
@Override
public Object deserialize(JsonParser p, DeserializationContext ctxt)
throws JacksonException
{
return _valueDeserializer.deserialize(p, ctxt);
}
@Override
protected void _set(DeserializationContext ctxt, Object instance, Object propName, Object value)
throws Exception
{
((ObjectNode) instance).set((String) propName, (JsonNode) value);
}
// Should not get called but...
@Override
public SettableAnyProperty withValueDeserializer(ValueDeserializer<Object> deser) {
throw new UnsupportedOperationException("Cannot call withValueDeserializer() on " + getClass().getName());
}
@Override
public int getParameterIndex() { return _parameterIndex; }
@Override
public Object createParameterObject() { return _nodeFactory.objectNode(); }
}
}
View on GitHub (pinned to a50c7d2a1d)
Solutions
- Avoid annotating ObjectNode/JsonNode creator parameters with @JsonAnySetter if a custom value deserializer is required.
- In any custom factory/modifier code, check the concrete SettableAnyProperty type before calling withValueDeserializer (skip JsonNodeParameterAnyProperty).
- Use a Map<String,Object> parameter type instead of ObjectNode if you need custom per-value deserialization on any-setter content.
- Register the custom deserializer at the module level so it is already resolved during construction rather than via contextual replacement.
Example fix
// before
@JsonCreator
public MyBean(@JsonAnySetter ObjectNode extra) { ... }
// factory calls withValueDeserializer -> throws
// after: use Map if custom deser needed, or don't customize
@JsonCreator
public MyBean(@JsonAnySetter Map<String,Object> extra) { ... } Defensive patterns
Strategy: type-guard
Validate before calling
// Check type before calling withValueDeserializer
if (!(settableAnyProp instanceof SettableAnyProperty.JsonNodeParameterAnyProperty)) {
settableAnyProp = settableAnyProp.withValueDeserializer(deser);
} Type guard
static boolean canReplaceDeserializer(SettableAnyProperty prop) {
return !(prop.getClass().getName().contains("JsonNodeParameterAnyProperty"));
} Try / catch
try {
prop = prop.withValueDeserializer(deser);
} catch (UnsupportedOperationException e) {
// JsonNodeParameterAnyProperty cannot be contextualized — skip
} Prevention
- Avoid @JsonAnySetter on ObjectNode/JsonNode creator parameters when custom deserializers are involved.
- Use Map<String,Object> instead of ObjectNode for any-setter with custom deser.
- Guard custom factory code against unsupported any-property types.
When it happens
Trigger: Defining @JsonAnySetter on a creator constructor parameter whose type is ObjectNode/JsonNode, combined with a custom deserializer or module that attempts contextualization via withValueDeserializer(). Subclassing SettableAnyProperty and routing through the JsonNodeParameterAnyProperty path while the framework attempts contextualizer replacement.
Common situations: Using a custom DeserializerFactory or BeanDeserializerModifier that calls withValueDeserializer on all any-properties indiscriminately. Mixing @JsonAnySetter with @JsonCreator on an ObjectNode-typed parameter while also registering a custom value deserializer.
Related errors
- Trying to resolve a forward reference with id [{}] that wasn
- Cannot call createParameterObject() on {}
- Cannot pass null property name
- Duplicate creator property "%s" (index %s vs %d) for type %s
- Conflicting %s creators: already had %s creator %s, encounte
AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06).
Data as JSON: /api/errors/65fb2f8f36066349.
Report an issue: GitHub.