Hi,
I'm trying using Spring's jsp message tag. I use the url declared in <welcome-file-list> in my web.xml to access the first page of my site, the following exception occurs :
My WebApplicationContext is loaded using:Code:java.lang.IllegalStateException: No WebApplicationContext found: not in a DispatcherServlet request? at org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:79)
The exception is thrown by Spring's RequestContextUtils.getWebApplicationContext:Code:<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
I think that the behaviour of getWebApplicationContext(ServletRequest request) is strange. Why dosn't it pass the ServletContext from the request instead of passing null? How can I use spring:message tag in pages not related to Spring (for example when I have login.jsp because of container managed security)?Code:public static WebApplicationContext getWebApplicationContext(ServletRequest request) throws IllegalStateException { return getWebApplicationContext(request, null); } public static WebApplicationContext getWebApplicationContext(ServletRequest request, ServletContext servletContext) throws IllegalStateException { WebApplicationContext webApplicationContext = (WebApplicationContext) request.getAttribute( DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (webApplicationContext == null) { if (servletContext == null) { throw new IllegalStateException("No WebApplicationContext found: not in a DispatcherServlet request?"); } webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (webApplicationContext == null) { throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); } } return webApplicationContext; }


Reply With Quote