Skip to content

Regression: @ComponentScan fails for AnnotationConfigWebApplicationContext [SPR-11647] #16270

@spring-projects-issues

Description

@spring-projects-issues

Robert Thaler opened SPR-11647 and commented

After upgrading to Spring Framework 4.0.3 we are receiving a NoSuchBeanDefinitionException on start up of our web application.

This did not occur using Spring Framework 4.0.2.

We have the following spring java configuration for the web application:

@Configuration
@Import( value = { ServiceConfig.class, ... } )
public class MainConfig {
  // ....
}

@ComponentScan( packages = { "some.service.package" } )
public class ServiceConfig {
}

The web.xml configuration looks as follows:

<context-param>
	<param-name>contextClass</param-name>
	<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
	
<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>my.webapp.config</param-value>
</context-param>

<listener>
	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

After some investigation I have found out that it works if I specify a distinct configuration class instead of a package.

So using my.webapp.config.MainConfig for the context param contextConfigLocation works, but if I have understood the documentation correctly, it should work with a package path too.


Affects: 4.0.3

Attachments:

1 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions