spring-projects/spring-framework · error · IllegalArgumentException
Unable to locate method [{methodName}] on bean [{targetBeanN
Error message
Unable to locate method [{methodName}] on bean [{targetBeanName}] What it means
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.
Source
Thrown at spring-aop/src/main/java/org/springframework/aop/config/MethodLocatingFactoryBean.java:78
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (!StringUtils.hasText(this.targetBeanName)) {
throw new IllegalArgumentException("Property 'targetBeanName' is required");
}
if (!StringUtils.hasText(this.methodName)) {
throw new IllegalArgumentException("Property 'methodName' is required");
}
Class<?> beanClass = beanFactory.getType(this.targetBeanName);
if (beanClass == null) {
throw new IllegalArgumentException("Can't determine type of bean with name '" + this.targetBeanName + "'");
}
this.method = BeanUtils.resolveSignature(this.methodName, beanClass);
if (this.method == null) {
throw new IllegalArgumentException("Unable to locate method [" + this.methodName +
"] on bean [" + this.targetBeanName + "]");
}
}
@Override
public @Nullable Method getObject() throws Exception {
return this.method;
}
@Override
public Class<Method> getObjectType() {
return Method.class;
}
@Override
public boolean isSingleton() {
return true;View on GitHub (pinned to 69bf83ad71)
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
Example fix
// before <property name="methodName" value="doWork"/> <!-- method renamed to execute --> // after <property name="methodName" value="execute"/>
Defensive patterns
Strategy: validation
Validate before calling
// Resolve eagerly to fail with a clearer message:
Class<?> c = beanFactory.getType(targetBeanName);
Method m = BeanUtils.resolveSignature(methodName, c);
if (m == null) throw new IllegalStateException("No method " + methodName + " on " + c); Type guard
private static boolean methodExists(Class<?> type, String signature) {
return type != null && BeanUtils.resolveSignature(signature, type) != null;
} Prevention
- When refactoring a method, grep the config for its name and update MethodLocatingFactoryBean references
- For overloaded methods, specify parameter types in the signature string
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Property 'targetBeanName' is required
- Property 'methodName' is required
- Can't determine type of bean with name '{targetBeanName}'
- Property 'target' is required
- 'target' needs to be a bean reference, not a bean name as va
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/fd5094d7d2dd0e0f.
Report an issue: GitHub.