{"record":{"id":"42190d6472f5b030","repo":"FasterXML/jackson-databind","slug":"unsupported-container-type-value-getclass-get","errorCode":null,"errorMessage":"Unsupported container type (${value.getClass().getName()}) when resolving reference '${_referenceName}'","messagePattern":"Unsupported container type \\((.+?)\\) when resolving reference '(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/impl/ManagedReferenceProperty.java","lineNumber":142,"sourceCode":"        Iterable<?> iterable = _toIterable(value);\n        for (Object obj : iterable) {\n            if (obj != null) {\n                _backProperty.set(ctxt, obj, instance);\n            }\n        }\n    }\n\n    private Iterable<?> _toIterable(Object value) {\n        if (value instanceof Collection<?> coll) {\n            return coll;\n        }\n        if (value instanceof Map<?,?> map) {\n            return map.values();\n        }\n        if (value instanceof Object[] obs) {\n            return Arrays.asList(obs);\n        }\n        throw new IllegalStateException(\"Unsupported container type (\" + value.getClass().getName()\n                + \") when resolving reference '\" + _referenceName + \"'\");\n    }\n}\n","sourceCodeStart":124,"sourceCodeEnd":146,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/impl/ManagedReferenceProperty.java#L124-L146","documentation":"ManagedReferenceProperty resolves a @JsonManagedReference/@JsonBackReference pair where the managed side is a container; _toIterable only accepts Collection, Map, or Object[]. If the resolved value is any other type (a Stream, Iterable-but-not-Collection, single object, or custom container), the back reference cannot be injected and an IllegalStateException is raised.","triggerScenarios":"A @JsonManagedReference field typed as Iterable (not a Collection), Stream, Iterator, or a custom aggregate; a single (non-container) value marked as a managed reference container mismatch with the actual data; mis-typing the back reference relationship on a non-standard collection.","commonSituations":"Using guava ImmutableList (ok, it's a Collection) vs guava FluentIterable (not a Collection -> fails); Stream-typed fields; domain types that wrap a collection but do not implement Collection/Map; @JsonManagedReference on a property whose runtime value is a single element where _isContainer was set true.","solutions":["Type the managed-reference container as a concrete Collection (List/Set), Map, or Object[] so _toIterable can handle it.","If using a third-party collection, convert it to a java.util collection before serialization, or annotate as a non-container reference.","Ensure _isContainer (set from the declared type at introspection) matches the runtime type of the value.","For Iterable-only types, switch to List or implement Collection."],"exampleFix":"// before\n@JsonManagedReference\nprivate FluentIterable<Item> items; // not a Collection -> throws on resolve\n\n// after\n@JsonManagedReference\nprivate List<Item> items; // Collection is supported","handlingStrategy":"validation","validationCode":"Object v = managedFieldValue;\nif (!(v instanceof Collection || v instanceof Map || v instanceof Object[])) {\n    throw new IllegalStateException(\"Unsupported managed-ref container: \" + v.getClass());\n}","typeGuard":"static boolean isSupportedManagedContainer(Object v) {\n    return v instanceof Collection<?> || v instanceof Map<?,?> || v instanceof Object[];\n}","tryCatchPattern":"try { mapper.readValue(json, Parent.class); }\ncatch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Unsupported container type\")) {\n        // retype the managed-ref field as List/Set/Map/Object[]\n    } else throw e;\n}","preventionTips":["Declare managed-reference containers as java.util.Collection, Map, or Object[].","Convert third-party Iterables to Lists before serialization."],"tags":["deserialization","managed-reference","container","back-reference"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}