FasterXML/jackson-databind · error · UnsupportedOperationException

Instances of {} should not get visited

Error message

Instances of {} should not get visited

What it means

Thrown by BeanProperty.Std.depositSchemaProperty() (an internal placeholder BeanProperty implementation) when it is inadvertently visited during JSON schema generation. The Std implementation is a minimal stand-in meant only to carry property metadata for contextual deserializer/serializer lookup; it intentionally cannot emit schema properties. If schema generation reaches this object, it indicates an internal wiring path that was never expected to execute.

Source

Thrown at src/main/java/tools/jackson/databind/BeanProperty.java:279

        @Override public JavaType getType() { return _type; }
        @Override public PropertyName getWrapperName() { return _wrapperName; }
        @Override public boolean isRequired() { return _metadata.isRequired(); }
        @Override public PropertyMetadata getMetadata() { return _metadata; }
        @Override public AnnotatedMember getMember() { return _member; }

        @Override
        public boolean isVirtual() { return false; }

        /**
         * Implementation of this method throws
         * {@link UnsupportedOperationException}, since instances of this
         * implementation should not be used as part of actual structure
         * visited. Rather, other implementations should handle it.
         */
        @Override
        public void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor,
                SerializationContext ctxt) {
            throw new UnsupportedOperationException("Instances of "+getClass().getName()+" should not get visited");
        }
    }

    /**
     * Alternative "Null" implementation that can be used in cases where a non-null
     * {@link BeanProperty} is needed
     */
    public static class Bogus implements BeanProperty
    {
        @Override
        public String getName() {
            return "";
        }

        @Override
        public PropertyName getFullName() {
            return PropertyName.NO_NAME;
        }

View on GitHub (pinned to 87876ca5c0)

Solutions

  1. Override depositSchemaProperty() in your custom serializer/property writer to be a no-op or to delegate to a real property instead of using BeanProperty.Std.
  2. Construct the BeanProperty with a concrete AnnotatedMember so the schema visitor has a real member to introspect.
  3. Avoid passing BeanProperty.Std instances into BeanPropertyWriter constructors that participate in schema generation.

Example fix

// before
BeanProperty prop = new BeanProperty.Std(name, type, wrapperName, member);
// after: provide a full implementation or skip schema visit
BeanProperty prop = new BeanProperty.Std(name, type, wrapperName, member) {
    @Override
    public void depositSchemaProperty(JsonObjectFormatVisitor v, SerializationContext c) {
        // no-op: this property does not contribute to schema
    }
};
Defensive patterns

Strategy: type-guard

Validate before calling

// Before schema generation, check if the property is a placeholder
if (property instanceof BeanProperty.Std) {
    // skip or replace with a real property before visiting
    return;
}

Type guard

boolean isVisitableBeanProperty(BeanProperty p) {
    return !(p instanceof BeanProperty.Std);
}

Prevention

When it happens

Trigger: Calling ObjectMapper.acceptJsonFormatVisitor() or generating a JSON Schema on a type whose serializer/property writer contains a BeanProperty.Std instance. This typically happens when a custom ValueSerializer or ValueDeserializerModifier constructs a BeanProperty.Std and registers it on a BeanPropertyWriter that then gets traversed by the format visitor.

Common situations: Custom serializers that reuse BeanProperty.Std as the property marker for properties that later get visited by schema generation. Also seen when third-party Jackson modules create writers without a real AnnotatedMember backing them.

Related errors


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