FasterXML/jackson-databind · error · IllegalArgumentException

Invalid Object Id definition for %s: cannot find property wi

Error message

Invalid Object Id definition for %s: cannot find property with name %s

What it means

Thrown while wiring @JsonIdentityInfo with a PropertyGenerator: the generator is told to use a specific property name as the id, but no settable property with that name exists on the bean. Abstract types are exempt (they defer to concrete subtypes), but concrete beans must own the named property.

Source

Thrown at src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java:424

        JavaType idType;
        SettableBeanProperty idProp;
        ObjectIdGenerator<?> gen;

        ObjectIdResolver resolver = ctxt.objectIdResolverInstance(beanDescRef.getClassInfo(), objectIdInfo);

        // Just one special case: Property-based generator is trickier
        if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work
            PropertyName propName = objectIdInfo.getPropertyName();
            idProp = deserBuilder.findProperty(propName);
            if (idProp == null) {
                // [databind#4014]: For abstract types (interfaces, abstract classes),
                // the builder may not have settable properties (no setter/field).
                // Concrete subtype deserializers will set up their own ObjectIdReader,
                // so we can safely skip it here for the abstract type.
                if (beanDescRef.getType().isAbstract()) {
                    return;
                }
                throw new IllegalArgumentException("Invalid Object Id definition for %s: cannot find property with name %s".formatted(
                        ClassUtil.getTypeDescription(beanDescRef.getType()),
                        ClassUtil.name(propName)));
            }
            idType = idProp.getType();
            gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope());
        } else {
            JavaType type = ctxt.constructType(implClass);
            idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0];
            idProp = null;
            gen = ctxt.objectIdGeneratorInstance(beanDescRef.getClassInfo(), objectIdInfo);
        }
        // also: unlike with value deserializers, let's just resolve one we need here
        ValueDeserializer<?> deser = ctxt.findRootValueDeserializer(idType);
        deserBuilder.setObjectIdReader(ObjectIdReader.construct(idType,
                objectIdInfo.getPropertyName(), gen, deser, idProp, resolver));
    }

    @SuppressWarnings("unchecked")

View on GitHub (pinned to a50c7d2a1d)

Solutions

  1. Add a property (field/getter/setter) matching the name in @JsonIdentityInfo(property=...).
  2. Correct the property name in the annotation to match an existing property.
  3. If the type is meant to be abstract, mark it abstract so the check is deferred to the concrete subtype.
  4. If property-based generation isn't required, switch to a different generator (SequenceGenerator, UUIDGenerator).

Example fix

// before
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "key")
class Item { Long id; String name; } // no 'key' property -> throws
// after
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
class Item { Long id; String name; }
Defensive patterns

Strategy: validation

Validate before calling

String idProp = "id";
if (Arrays.stream(Item.class.getDeclaredFields())
        .noneMatch(f -> f.getName().equals(idProp))) {
    throw new IllegalStateException("Item has no property '" + idProp
        + "' referenced by @JsonIdentityInfo");
}

Prevention

When it happens

Trigger: @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") on a concrete class that has no field/getter/setter named 'id', or where the name was misspelled/renamed/hidden.

Common situations: Renaming the id property without updating the annotation; copying @JsonIdentityInfo from another class with a different id field name; the property being filtered out by a view or visibility rule.

Related errors


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