Skip to content

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

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions