Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering of ServletContextAware and ApplicationContextAware callbacks makes testing FreeMarkerView (and similar classes) impossible [SPR-5398] #10071

Closed
spring-projects-issues opened this issue Jan 6, 2009 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Dave Syer opened SPR-5398 and commented

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())?


Affects: 2.5.6, 3.0 M1

@spring-projects-issues
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants