Oliver Drotbohm opened SPR-12553 and commented
Wehen setting up a MockMvc instance from a WebApplicationContext the ServletContext attribute WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE does not get populated. View technologies used for rendering views often lookup the ApplicationContext using WebApplicationContextUtils.getRequiredWebApplicationContext(…). That method expects the ApplicationContext to be registered under said attribute.
I currently work around the issue by manually setting the attribute:
context.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
Affects: 4.1.3
Referenced from: commits f6d2fe4, 32aafb2, 33b9bd7