{"record":{"id":"3f79df64b06afa3f","repo":"spring-projects/spring-framework","slug":"could-not-find-original-class-structure","errorCode":null,"errorMessage":"Could not find original class structure","messagePattern":"Could not find original class structure","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java","lineNumber":434,"sourceCode":"\t\t\tif (this.fieldName != null) {\n\t\t\t\tthis.field = this.declaringClass.getDeclaredField(this.fieldName);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this.methodName != null) {\n\t\t\t\t\tthis.methodParameter = new MethodParameter(\n\t\t\t\t\t\t\tthis.declaringClass.getDeclaredMethod(this.methodName, this.parameterTypes), this.parameterIndex);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.methodParameter = new MethodParameter(\n\t\t\t\t\t\t\tthis.declaringClass.getDeclaredConstructor(this.parameterTypes), this.parameterIndex);\n\t\t\t\t}\n\t\t\t\tfor (int i = 1; i < this.nestingLevel; i++) {\n\t\t\t\t\tthis.methodParameter = this.methodParameter.nested();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Throwable ex) {\n\t\t\tthrow new IllegalStateException(\"Could not find original class structure\", ex);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":416,"sourceCodeEnd":439,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/factory/config/DependencyDescriptor.java#L416-L439","documentation":"Thrown as an IllegalStateException during deserialization of a DependencyDescriptor: readObject restores the reflective Field/MethodParameter handles from the stored declaring class and member name; if the class no longer has that field/method/constructor (renamed, removed, signature changed, class missing), the reflective lookup throws and is wrapped with this message.","triggerScenarios":"Deserializing a DependencyDescriptor (across an RPC boundary, in a session, or cached) on a JVM where the declaring class's structure does not match what was serialized: getDeclaredField/getDeclaredMethod/getDeclaredConstructor fails. Triggered inside readObject when reconstructing this.field or this.methodParameter.","commonSituations":"Distributing a DependencyDescriptor between nodes running different versions of the application where a field/method was renamed or deleted; serializing a descriptor that points at a class that was later removed; refactoring an @Autowired field's name after a descriptor was cached; classloader differences hiding the expected member; cross-major Spring upgrade that changed reflective metadata.","solutions":["Ensure both producer and consumer of the serialized descriptor run the same application/class versions so the member still exists.","Avoid serializing DependencyDescriptor across version boundaries; pass plain bean names/types and re-resolve on the receiving side.","If you control the injection point, keep the field/method name and signature stable across versions, or invalidate caches after refactors.","Invalidate or migrate any persistent cache holding serialized descriptors when the class structure changes.","Inspect the 'caused by' (NoSuchFieldException / NoSuchMethodException) to find which member is missing, then restore or rename it back."],"exampleFix":"// before: serializing a DependencyDescriptor across versions\n// node A (v1): field 'orderRepo'  -> node B (v2): field renamed 'repository'\nObjectOutputStream oos = ...;\noos.writeObject(dependencyDescriptor);\n\n// after: don't ship the descriptor; ship the bean name and re-resolve\noos.writeObject(descriptor.getDependencyType());\noos.writeObject(beanName);\n// receiver: beanFactory.getBean(beanName, type);","handlingStrategy":"validation","validationCode":"// Verify the reflective member still exists before deserializing/using\nClass<?> c = descriptor.getDeclaringClass();\nif (descriptor.getFieldName() != null) {\n    c.getDeclaredField(descriptor.getFieldName()); // throws if missing\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not serialize DependencyDescriptor across application versions.","Pass plain bean name + type over the wire and re-resolve on the receiver.","Invalidate cached descriptors when class structure changes.","Keep field/method names stable if descriptors must be cached."],"tags":["spring","serialization","reflection","version-drift","distributed"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}