{"record":{"id":"a6080b7fda6b3f97","repo":"FasterXML/jackson-databind","slug":"cannot-deserialize-proxy-class-as-a-bean","errorCode":null,"errorMessage":"Cannot deserialize Proxy class {} as a Bean","messagePattern":"Cannot deserialize Proxy class (.+?) as a Bean","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java","lineNumber":1071,"sourceCode":"    /**********************************************************\n     */\n\n    /**\n     * Helper method used to skip processing for types that we know\n     * cannot be (i.e. are never consider to be) beans:\n     * things like primitives, Arrays, Enums, and proxy types.\n     *<p>\n     * Note that usually we shouldn't really be getting these sort of\n     * types anyway; but better safe than sorry.\n     */\n    protected boolean isPotentialBeanType(Class<?> type)\n    {\n        String typeStr = ClassUtil.canBeABeanType(type);\n        if (typeStr != null) {\n            throw new IllegalArgumentException(\"Cannot deserialize Class \"+type.getName()+\" (of type \"+typeStr+\") as a Bean\");\n        }\n        if (ClassUtil.isProxyType(type)) {\n            throw new IllegalArgumentException(\"Cannot deserialize Proxy class \"+type.getName()+\" as a Bean\");\n        }\n        // [databind#3229]: Local/anonymous classes cannot be instantiated but\n        //   can still be updated via `readerForUpdating()`. So let them through\n        //   here; if actual instantiation is attempted, `ValueInstantiator` will\n        //   fail with a clear error.\n        return true;\n    }\n\n    /**\n     * Helper method that will check whether given raw type is marked as always ignorable\n     * (for purpose of ignoring properties with type)\n     */\n    protected boolean isIgnorableType(DeserializationContext ctxt, BeanPropertyDefinition propDef,\n            Class<?> type, Map<Class<?>,Boolean> ignoredTypes)\n    {\n        Boolean status = ignoredTypes.get(type);\n        if (status != null) {\n            return status.booleanValue();","sourceCodeStart":1053,"sourceCodeEnd":1089,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java#L1053-L1089","documentation":"Thrown by BeanDeserializerFactory.isPotentialBeanType when the target class is a JDK dynamic proxy (java.lang.reflect.Proxy subclass). Proxies have no real fields or constructors Jackson can introspect, so bean deserialization is impossible and rejected up front.","triggerScenarios":"Deserializing into a class that is or extends java.lang.reflect.Proxy — most often a Hibernate lazy-loading proxy class, a Spring AOP proxy class, or a manually-proxied interface that leaked into the target type.","commonSituations":"Passing a Hibernate uninitialized entity proxy class as the deserialization target; round-tripping a serialized proxy back into the proxy class; AOP-wrapped domain objects reaching the mapper.","solutions":["Deserialize into the concrete entity class, not the proxy class.","For Hibernate, ensure entities are initialized/deproxied first (Hibernate.unproxy / HibernateProxyHelper.getClassWithoutInitializingProxy).","Use a mixin or @JsonTypeInfo to map the proxy class to its concrete base.","Keep persistence/AOP concerns out of the Jackson boundary; convert to plain DTOs first."],"exampleFix":"// before\nObject entity = mapper.readValue(json, hibernateProxy.getClass()); // Proxy class -> throws\n// after\nClass<?> concrete = Hibernate.unproxy(hibernateProxy).getClass();\nObject entity = mapper.readValue(json, concrete);","handlingStrategy":"validation","validationCode":"Class<?> target = value.getClass();\nif (java.lang.reflect.Proxy.isProxyClass(target)) {\n    throw new IllegalArgumentException(\"Cannot deserialize into proxy class \" + target);\n}\nmapper.readValue(json, target);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip proxies (Hibernate.unproxy, AopUtils.getTargetClass) before using a class as a deserialization target.","Never round-trip proxy instances through JSON; map to plain DTOs.","Keep persistence/AOP concerns out of the Jackson (de)serialization boundary."],"tags":["deserialization","proxy","hibernate","aop"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}