• Andy Wilkinson's avatar
    Use ServletContainerInitializers to start servers · e57b0e00
    Andy Wilkinson authored
    The Servlet spec prohibits ServletContextListeners from being registered
    programatically other than from with a call to
    `ServletContainerInitializer.onStartup`. This restriction is not
    consistently enforced by the various embedded servlet containers that
    Boot supports:
    
    - Jetty 8 does not enforce the restriction.
    - Jetty 9 enforces the restriction. We were working around it be calling
      setExendedListenerTypes(true) on the context.
    - Tomcat somewhat enforces the restriction: it doesn't allow a
      ServletContextListener to be added once the first
      ServletContextListener has been called. We were using a
      LifecycleListener to drive the ServletContextListeners.
    - Undertow enforces the restriction and we were not working around it.
      This resulted in gh-2192 being raised.
    
    ServletListenerRegistrationBean is a ServletContextListener and is used
    to register listeners, including ServletContextListeners, with the
    servlet context. To adhere to the letter of the servlet spec this means
    that ServletListenerRegistrationBeans need to be called from with
    ServletContainerInitializer.onStartup. This commit updates all of the
    embedded servlet container implementations to use a
    ServletContainerInitializer to drive any ServletContextInitializers.
    
    This makes the lifecycle more consistent across the supported containers
    and allows ServletListenerRegistrationBeans to be able to register
    ServletContextListeners on all supported embedded containers.
    
    Fixes gh-2192
    e57b0e00
Name
Last commit
Last update
docs Loading commit data...
eclipse Loading commit data...
spring-boot Loading commit data...
spring-boot-actuator Loading commit data...
spring-boot-autoconfigure Loading commit data...
spring-boot-cli Loading commit data...
spring-boot-dependencies Loading commit data...
spring-boot-deployment-tests Loading commit data...
spring-boot-docs Loading commit data...
spring-boot-full-build Loading commit data...
spring-boot-integration-tests Loading commit data...
spring-boot-parent Loading commit data...
spring-boot-samples Loading commit data...
spring-boot-starters Loading commit data...
spring-boot-tools Loading commit data...
spring-boot-versions Loading commit data...
.gitignore Loading commit data...
.settings-template.xml Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.adoc Loading commit data...
LICENSE.txt Loading commit data...
README.adoc Loading commit data...
pom.xml Loading commit data...