Skip to content

WebApplicationInitializer with AnnotationConfigWebApplicationContext parent gets reset to null by ContextLoaderListener [SPR-9591] #14225

@spring-projects-issues

Description

@spring-projects-issues

Kirk Rasmussen opened SPR-9591 and commented

org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext, ServletContext)

The following code ignores that the parent was already set previously and ends up setting the parent to null.

		// Determine parent for root web application context, if any.
		ApplicationContext parent = loadParentContext(sc);

		wac.setParent(parent);

The documentation for org.springframework.web.context.ContextLoaderListener.ContextLoaderListener(WebApplicationContext) doesn't match the implementation for condition (b)

The context may or may not yet be refreshed. If it (a) is an implementation of ConfigurableWebApplicationContext and (b) has not already been refreshed (the recommended approach), then the following will occur:

It appears that refresh is ALWAYS called:

org.springframework.web.context.ContextLoader.initWebApplicationContext(ServletContext)

			if (this.context instanceof ConfigurableWebApplicationContext) {
				configureAndRefreshWebApplicationContext((ConfigurableWebApplicationContext)this.context, servletContext);


Issue Links:

Backported to: 3.1.4

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions