Skip to content

@Inject Autowiring by type fails on FactoryBeans and injected refs the FactoryBean depends on [SPR-7450] #12108

@spring-projects-issues

Description

@spring-projects-issues

Keith Donald opened SPR-7450 and commented

Ran into a rather odd problem. Testing against latest 3.0.4 nightly build.

The following fails with a no default constructor found exception:

<beans:bean id="badgeSystem" class="com.springsource.greenhouse.badge.BadgeSystemFactoryBean"/>
	
<beans:bean id="badgeRepository" class="com.springsource.greenhouse.badge.JdbcBadgeRepository"/>

The following works:

<beans:bean id="badgeSystem" class="com.springsource.greenhouse.badge.BadgeSystemFactoryBean">
	<beans:constructor-arg ref="badgeRepository" />
</beans:bean>
	
<beans:bean id="badgeRepository" class="com.springsource.greenhouse.badge.JdbcBadgeRepository">
	<beans:constructor-arg ref="jdbcTemplate" />
</beans:bean>

The injection points:

@Inject
public BadgeSystemFactoryBean(BadgeRepository badgeRepository) {
	this.badgeRepository = badgeRepository;
}


@Inject
public JdbcBadgeRepository(JdbcTemplate jdbcTemplate) {
	this.jdbcTemplate = jdbcTemplate;
}

context:annotation-config is turned on.

Strangely, removing the FactoryBean and leaving just the Repository def relying on byType autowiring works:

<beans:bean id="badgeRepository" class="com.springsource.greenhouse.badge.JdbcBadgeRepository" />

Is there something special related to FactoryBean autowiring I'm missing?


Affects: 3.0.3

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions