Details
Description
CXFServlet.java line 136 obtains the Spring application context from the servlet context:
if (ctx == null)
{ ctx = (ApplicationContext)svCtx .getAttribute("org.springframework.web.context.WebApplicationContext.ROOT"); }If the Spring application context failed to load however, Spring (somewhat inexplicably) sets this attribute to be the exception rather than the context. See org/springframework/web/context/ContextLoader.java line 202:
catch (RuntimeException ex)
{ logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; }To avoid repeated ClassCastExceptions that obscure the underlying problem with the Spring application context, CXFServlet should check the type of the attribute before attempting to cast to ApplicationContext:
if (ctx == null) {
Object ctxObject = svCtx
.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
if (ctxObject instanceof ApplicationContext)
}