{"record":{"id":"fd5094d7d2dd0e0f","repo":"spring-projects/spring-framework","slug":"unable-to-locate-method-methodname-on-bean-t","errorCode":null,"errorMessage":"Unable to locate method [{methodName}] on bean [{targetBeanName}]","messagePattern":"Unable to locate method \\[(.+?)\\] on bean \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java","lineNumber":78,"sourceCode":"\t}\n\n\t@Override\n\tpublic void setBeanFactory(BeanFactory beanFactory) {\n\t\tif (!StringUtils.hasText(this.targetBeanName)) {\n\t\t\tthrow new IllegalArgumentException(\"Property 'targetBeanName' is required\");\n\t\t}\n\t\tif (!StringUtils.hasText(this.methodName)) {\n\t\t\tthrow new IllegalArgumentException(\"Property 'methodName' is required\");\n\t\t}\n\n\t\tClass<?> beanClass = beanFactory.getType(this.targetBeanName);\n\t\tif (beanClass == null) {\n\t\t\tthrow new IllegalArgumentException(\"Can't determine type of bean with name '\" + this.targetBeanName + \"'\");\n\t\t}\n\t\tthis.method = BeanUtils.resolveSignature(this.methodName, beanClass);\n\n\t\tif (this.method == null) {\n\t\t\tthrow new IllegalArgumentException(\"Unable to locate method [\" + this.methodName +\n\t\t\t\t\t\"] on bean [\" + this.targetBeanName + \"]\");\n\t\t}\n\t}\n\n\n\t@Override\n\tpublic @Nullable Method getObject() throws Exception {\n\t\treturn this.method;\n\t}\n\n\t@Override\n\tpublic Class<Method> getObjectType() {\n\t\treturn Method.class;\n\t}\n\n\t@Override\n\tpublic boolean isSingleton() {\n\t\treturn true;","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java#L60-L96","documentation":"Once the bean's class is known, MethodLocatingFactoryBean resolves the method via BeanUtils.resolveSignature(methodName, beanClass) (line 75). If resolveSignature returns null - i.e. no method of that name/signature exists on the class - Spring throws this IllegalArgumentException naming both the method and the bean.","triggerScenarios":"methodName does not match any method on the target bean's class; the method exists only on a superclass that ClassUtils cannot reach; the method was renamed/removed in a refactor; using a signature string with wrong parameter types.","commonSituations":"Refactor that renamed or deleted the target method while leaving the config stale; method is private and not resolvable; typo in method name; the bean's actual runtime class differs from the expected one (e.g. scoped-proxy or AOP-proxied bean whose getType returns the interface).","solutions":["Open the target bean's class and confirm a method with the exact name exists and is public/non-private","For overloaded methods, supply a typed signature like \"doWork(int,String)\" (resolveSignature supports it) instead of just \"doWork\"","If the bean is proxied/scoped, make sure the method is declared on the interface or class that getType returns"],"exampleFix":"// before\n<property name=\"methodName\" value=\"doWork\"/>  <!-- method renamed to execute -->\n\n// after\n<property name=\"methodName\" value=\"execute\"/>","handlingStrategy":"validation","validationCode":"// Resolve eagerly to fail with a clearer message:\nClass<?> c = beanFactory.getType(targetBeanName);\nMethod m = BeanUtils.resolveSignature(methodName, c);\nif (m == null) throw new IllegalStateException(\"No method \" + methodName + \" on \" + c);","typeGuard":"private static boolean methodExists(Class<?> type, String signature) {\n  return type != null && BeanUtils.resolveSignature(signature, type) != null;\n}","tryCatchPattern":null,"preventionTips":["When refactoring a method, grep the config for its name and update MethodLocatingFactoryBean references","For overloaded methods, specify parameter types in the signature string"],"tags":["spring-aop","config","factory-bean","method-not-found"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}