I can tell you why it happens.
I'm assuming you're registering your DelegatingFilterProxy
in a WebApplicationInitializer
subclass, maybe an AbstractDispatcherServletInitializer
subclass.
Regardless, this class is completely independent of actions to the ApplicationContext
. The Servlet container scans your classpath and finds Spring's SpringServletContainerInitializer
which finds your WebApplicationInitializer
implementation and runs it. The DelegatingFilterProxy
is then registered specifying a bean name.
When the first request comes in to your server, the DelegatingFilterProxy
will attempt to find its delegate in the ApplicationContext
and set it to its delegate field. It does this only if its current delegate is null
. So a refresh of the context won't affect it.
There are possible solutions here.