FasterXML/jackson-databind · error · IllegalArgumentException
Cannot pass null resolver
Error message
Cannot pass null resolver
What it means
Thrown by MapperBuilder.addAbstractTypeResolver when the supplied resolver is null. The builder treats null as a programming error rather than a silent no-op, because silently skipping it would mask a wiring bug in the caller.
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 a50c7d2a1d)
Solutions
- Guard the call site: only register the resolver when you hold a non-null instance.
- If the resolver is optional, wrap the call in `if (resolver != null)` or Objects.requireNonNull first.
- Fix the upstream lookup/DI so a real resolver is produced.
Example fix
// before
builder.addAbstractTypeResolver(maybeResolver()); // maybeResolver() returns null -> throws
// after
AbstractTypeResolver resolver = maybeResolver();
if (resolver != null) {
builder.addAbstractTypeResolver(resolver);
} Defensive patterns
Strategy: validation
Validate before calling
AbstractTypeResolver resolver = obtainResolver(); Objects.requireNonNull(resolver, "AbstractTypeResolver must not be null"); builder.addAbstractTypeResolver(resolver);
Prevention
- Treat builder add* methods as non-null APIs; never pass through possibly-null lookups.
- Wrap conditional registration in `if (resolver != null)` when the resolver is genuinely optional.
- Use Objects.requireNonNull at the call site to fail fast with a clear message.
When it happens
Trigger: Calling mapperBuilder.addAbstractTypeResolver(null), or passing a lookup/DI result that resolved to null (e.g. Optional.orElse(null) or an unset bean).
Common situations: Conditional configuration where the resolver only sometimes exists; a refactor that left a null in place; a DI container failing to inject the bean; a feature flag disabling the resolver but not the registration call.
Related errors
- Cannot pass null Deserializers
- Cannot pass null KeyDeserializers
- Cannot pass null modifier
- Cannot pass null resolver
- AnnotationIntrospector returned Converter definition of type
AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06).
Data as JSON: /api/errors/2e085288a1d36974.
Report an issue: GitHub.