Skip to content

Improve error messaging when factory-method is not found [SPR-5475] #10148

@spring-projects-issues

Description

@spring-projects-issues

Alef Arendsen opened SPR-5475 and commented

If I use a factory-method without an argument, but in xml use a constructor+argument, I get quite a vague error message. Consider the following:

public aspect LoggingAspect {} // a bunch of stuff, but no constructors obviously

<bean class="com.mycompany.LoggingAspect" factory-method="aspectOf">
<constructor-arg ref="stats"/>
</bean>

Renders the following error. Can we improve this to give a hint that there no arguments in the method?? Or something similar??

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mycompany.LoggingAspect#0' defined in class path resource [context.xml]: No matching factory method found: factory method 'aspectOf'
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:901)


Affects: 2.5.6

Attachments:

Referenced from: commits 351e72b

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions