{"record":{"id":"682f4d69d225467b","repo":"FasterXML/jackson-databind","slug":"cannot-deserialize-proxy-class-type-getname-a","errorCode":null,"errorMessage":"Cannot deserialize Proxy class ${type.getName()} 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/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/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 (ClassUtil.isProxyType true -- class name starts with the proxy prefix). Jackson cannot instantiate or populate a java.lang.reflect.Proxy-backed class as a bean because its invocation handler is opaque, so it rejects it up front.","triggerScenarios":"Calling readValue(..., MyClass.class) (or forcing bean deserialization) where the runtime class is a Proxy generated by java.lang.reflect.Proxy, or a custom AbstractTypeResolver/introspector pointing at a proxy class.","commonSituations":"Passing a proxy instance's class (e.g., from a framework AOP/interceptor) as the target type; binding to an interface that has been proxied; Spring/Hibernate proxies leaking into Jackson as target types.","solutions":["Deserialize into a concrete POJO class (the un-proxied class), not the proxy class.","Unwrap the proxy (e.g. Spring's AopProxyUtils.getSingletonTarget / HibernateProxyHelper) before serializing/deserializing.","Register a mix-in or custom deserializer that targets the real class behind the proxy.","Avoid using proxy classes as Jackson target types; use the real interface/implementation."],"exampleFix":"// before: target is a proxied class\nObject read = mapper.readValue(json, proxiedInstance.getClass());\n\n// after: target the real class behind the proxy\nClass<?> real = AopProxyUtils.proxiedUserInterfaces(proxiedInstance)[0];\nObject read = mapper.readValue(json, real);","handlingStrategy":"type-guard","validationCode":"Class<?> type = instance.getClass();\nif (ClassUtil.isProxyType(type)) {\n    throw new IllegalArgumentException(type + \" is a Proxy; use the real class\");\n}\nmapper.readValue(json, type);","typeGuard":"boolean isProxiable(Class<?> c) {\n    return !ClassUtil.isProxyType(c);\n}","tryCatchPattern":null,"preventionTips":["Deserialize into concrete POJO classes, not proxy classes.","Unwrap framework proxies (Spring/Hibernate) before binding.","Register mixins targeting the real interface/class."],"tags":["jackson","deserialization","bean","proxy","aop","type-mismatch"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}