diff --git a/config/src/main/java/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java b/config/src/main/java/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java index 3cc0068f72..996a6741ee 100644 --- a/config/src/main/java/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java +++ b/config/src/main/java/org/springframework/security/config/annotation/web/AbstractRequestMatcherRegistry.java @@ -30,6 +30,9 @@ import javax.servlet.ServletContext; import javax.servlet.ServletRegistration; import javax.servlet.http.HttpServletRequest; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpMethod; @@ -75,6 +78,8 @@ public abstract class AbstractRequestMatcherRegistry { AbstractRequestMatcherRegistry.class.getClassLoader()); } + private final Log logger = LogFactory.getLog(getClass()); + protected final void setApplicationContext(ApplicationContext context) { this.context = context; } @@ -326,6 +331,10 @@ public abstract class AbstractRequestMatcherRegistry { matchers.add(resolve(ant, mvc, servletContext)); } else { + this.logger + .warn("The ServletRegistration API was not available at startup time. This may be due to a misconfiguration; " + + "if you are using AbstractSecurityWebApplicationInitializer, please double-check the recommendations outlined in " + + "https://docs.spring.io/spring-security/reference/servlet/configuration/java.html#abstractsecuritywebapplicationinitializer-with-spring-mvc"); matchers.add(new DeferredRequestMatcher((request) -> resolve(ant, mvc, request.getServletContext()), mvc, ant)); }