FasterXML/jackson-databind · error · IllegalArgumentException

Cannot pass null resolver

Error message

Cannot pass null resolver

What it means

Thrown by MapperBuilder.addAbstractTypeResolver(AbstractTypeResolver) when the argument is null. AbstractTypeResolver instances remap abstract types to concrete subtypes during deserialization; a null entry would produce gaps in the resolver chain, so Jackson rejects it at configuration time.

Solutions

  1. Guard the call: only invoke addAbstractTypeResolver(resolver) when resolver != null.
  2. If you want to disable resolution, omit the call or use clear/replace APIs rather than passing null.
  3. Ensure the factory/DI lookup producing the resolver never returns null.

Example fix

// before
builder.addAbstractTypeResolver(maybeResolver());

// after
AbstractTypeResolver r = maybeResolver();
if (r != null) {
    builder.addAbstractTypeResolver(r);
}
Defensive patterns

Strategy: validation

Validate before calling

AbstractTypeResolver resolver = maybeResolver();
if (resolver == null) {
    // skip
} else {
    builder.addAbstractTypeResolver(resolver);
}

Prevention

When it happens

Trigger: Calling JsonMapper.builder().addAbstractTypeResolver(null) (directly or via a variable/expression that evaluates to null).

Common situations: Conditionally registering a resolver and omitting the null check; refactoring that replaces a resolver instance with a lookup that can return null; DI wiring missing the bean.

Related errors


AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11). Data as JSON: /api/errors/2e085288a1d36974. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/tools/jackson/databind/cfg/MapperBuilder.java:1496

        return _this();
    }

    /**
     * Method that may be used to remove all {@link DeserializationProblemHandler}s added
     * to this builder (if any).
     */
    public B clearProblemHandlers() {
        _problemHandlers = null;
        return _this();
    }

    /**
     * Method for inserting specified {@link AbstractTypeResolver} as the first resolver
     * in chain of possibly multiple resolvers.
     */
    public B addAbstractTypeResolver(AbstractTypeResolver resolver) {
        if (resolver == null) {
            throw new IllegalArgumentException("Cannot pass null resolver");
        }
        _abstractTypeResolvers = ArrayBuilders.insertInListNoDup(_abstractTypeResolvers, resolver);
        return _this();
    }

    /*
    /**********************************************************************
    /* Changing settings, date/time
    /**********************************************************************
     */

    /**
     * Method for configuring the default {@link DateFormat} to use when serializing time
     * values as Strings, and deserializing from JSON Strings.
     * If you need per-request configuration, factory methods in
     * {@link ObjectReader} and {@link ObjectWriter} instead.
     */
    public B defaultDateFormat(DateFormat f) {

View on GitHub (pinned to 87876ca5c0)