spring-framework / org.springframework.web.context.support / WebApplicationContextUtils / getRequiredWebApplicationContext

getRequiredWebApplicationContext

open static fun getRequiredWebApplicationContext(sc: ServletContext): WebApplicationContext

Find the root WebApplicationContext for this web app, typically loaded via org.springframework.web.context.ContextLoaderListener.

Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.

Parameters

sc - ServletContext to find the web application context for

Exceptions

IllegalStateException - if the root WebApplicationContext could not be found

Return
the root WebApplicationContext for this web app

See Also
org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE