You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ordering of ServletContextAware and ApplicationContextAware callbacks makes testing FreeMarkerView (and similar classes) impossible [SPR-5398] #10071
Ordering of ServletContextAware and ApplicationContextAware callbacks makes testing servlet aware components impossible. I want to test a configuration that contains a FreeMarkerView (which is ServletContextAware), so I added a ServletContextAwareProcessor to my test config, with a MockServletContext. Unfortunately this doesn't work because FreeMarkerView has a base class which is ApplicationContextAware, and it assumes that either the ServletContext is already set or the ApplicationContext is an instance of WebApplicationContext, and neither is the case. But the ServletContext is available, and will eventually be set, so the initialisation is just happening too eagerly. Is it possible to put it in a more orthodox place (like afterPropertiesSet())?
I've addressed this for FreeMarkerView and also for ResourceBundleViewResolver and XmlViewResolver, all of which initialized in the initApplicationContext callback while actually being dependent on the ServletContext as well... They are simply performing that initialization in afterPropertiesSet now, as you suggested.
Actually, FreeMarkerView performs it in an initServletContext callback now, since its initialization is very much based on the ServletContext. The original problem should nevertheless disappear.
Activity
spring-projects-issues commentedon Mar 25, 2009
Juergen Hoeller commented
I've addressed this for FreeMarkerView and also for ResourceBundleViewResolver and XmlViewResolver, all of which initialized in the initApplicationContext callback while actually being dependent on the ServletContext as well... They are simply performing that initialization in afterPropertiesSet now, as you suggested.
Juergen
spring-projects-issues commentedon Mar 25, 2009
Juergen Hoeller commented
Actually, FreeMarkerView performs it in an initServletContext callback now, since its initialization is very much based on the ServletContext. The original problem should nevertheless disappear.