FasterXML/jackson-databind · error · IllegalArgumentException

Cannot pass null resolver

Error message

Cannot pass null resolver

What it means

DeserializerFactoryConfig.withValueInstantiators(ValueInstantiators) registers a provider of custom ValueInstantiators (used to override how POJOs are constructed). It rejects null with a clear message; passing null would break the instantiator-resolution chain inside BeanDeserializerFactory. Note the message says 'resolver' (the internal term) while the parameter/type is ValueInstantiators.

Source

Thrown at src/main/java/tools/jackson/databind/cfg/DeserializerFactoryConfig.java:145

        ValueDeserializerModifier[] all = ArrayBuilders.insertInListNoDup(_modifiers, modifier);
        return new DeserializerFactoryConfig(_additionalDeserializers, _additionalKeyDeserializers,
                all, _valueInstantiators);
    }

    /**
     * Fluent/factory method used to construct a configuration object that
     * has same configuration as this instance plus specified additional
     * value instantiator provider object.
     * Added instantiator provider has the highest priority (that is, it
     * gets called before any already registered resolver).
     *
     * @param instantiators Object that can provide {@link tools.jackson.databind.deser.ValueInstantiator}s for
     *    constructing POJO values during deserialization
     */
    public DeserializerFactoryConfig withValueInstantiators(ValueInstantiators instantiators)
    {
        if (instantiators == null) {
            throw new IllegalArgumentException("Cannot pass null resolver");
        }
        ValueInstantiators[] all = ArrayBuilders.insertInListNoDup(_valueInstantiators, instantiators);
        return new DeserializerFactoryConfig(_additionalDeserializers, _additionalKeyDeserializers,
                _modifiers, all);
    }

    public boolean hasDeserializers() { return _additionalDeserializers.length > 0; }

    public boolean hasKeyDeserializers() { return _additionalKeyDeserializers.length > 0; }

    public boolean hasDeserializerModifiers() { return _modifiers.length > 0; }

    public boolean hasValueInstantiators() { return _valueInstantiators.length > 0; }

    public Iterable<Deserializers> deserializers() {
        return new ArrayIterator<Deserializers>(_additionalDeserializers);
    }

View on GitHub (pinned to a50c7d2a1d)

Solutions

  1. Guard registration: if (vi != null) cfg.withValueInstantiators(vi).
  2. Ensure the ValueInstantiators and its underlying ValueInstantiator factory are non-null (inject eagerly).
  3. Filter nulls when registering a list of instantiator providers.
  4. If no custom instantiation is needed, simply don't register rather than registering null.

Example fix

// before
ValueInstantiators vi = customInst ? new MyInstantiators(beanFactory) : null;
cfg.withValueInstantiators(vi); // throws
// after
ValueInstantiators vi = customInst ? new MyInstantiators(beanFactory) : null;
if (vi != null) cfg.withValueInstantiators(vi);
Defensive patterns

Strategy: validation

Validate before calling

ValueInstantiators vi = ...;
if (vi == null) throw new IllegalArgumentException("ValueInstantiators must not be null");
cfg.withValueInstantiators(vi);

Type guard

// non-null reference check

Try / catch

try {
    cfg.withValueInstantiators(vi);
} catch (IllegalArgumentException e) {
    if (e.getMessage().equals("Cannot pass null resolver")) {
        // note: message says 'resolver', argument is 'instantiators'
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling config.withValueInstantiators(null); a module registering instantiators conditionally and forwarding null; a DI-provided ValueInstantiators bean that is null because a dependency (e.g. a factory) is missing.

Common situations: Custom entity/record instantiation via a module where the instantiator is built from optional deps; Spring bean for ValueInstantiators absent; refactoring that left a null field plumbed into registration; mixing up the parameter name 'instantiators' with the message term 'resolver' and assuming a different argument is at fault.

Related errors


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