spring-boot: Embedded Tomcat does not honor ServletContainerInitializers
Currently, the embedded Tomcat container does not detect and execute ServletContainerInitializers
. This means that dependencies that use them are never called and therefore are unable to contribute to the running application.
The embedded Tomcat container should be enhanced such that it properly notices the ServletContainerInitializers
on the Application’s classpath and executes them.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 22 (15 by maintainers)
Links to this issue
Commits related to this issue
- Enable javax.servlet.ServletContainerInitializer for embedded tomcat (see #321) — committed to felixbarny/spring-boot by deleted user 9 years ago
@philwebb could you be a bit more explicit what lead you to this design decision? What’s problematic about the search algorithm? Where in the boot source code do you disable that feature? Why wouldn’t you want the
ServletContainerInitializer
to be executed when you runjava -jar
? Would you consider supportingServletContainerInitializer
if some of the issues with it could be resolved?Also it’s not magical to execute all
ServletContainerInitializer
s.java.util.ServiceLoader.load(javax.servlet.ServletContainerInitializer)
should do the trick as all implementations of that interface have to be listed in/META-INF/services/javax.servlet.ServletContainerInitializer
.Servlet 3.0 made a really good job at defining this interface and the
@Web*
annotations as it makes it possible to write modular extensions to web applications (like stagemonitor) that just have to be on the classpath to be active and that are completely technology agnostic. It’s really a pity that boot beaks the spec multiple times (neitherServletContainerInitializer
nor@Web*
annotations are supported) which makes these mechanisms useless because they don’t work with boot, which is a (btw great) technology that just can’t be ignored.The goal of these servlet 3.0 mechanisms is to enable integration of standardized components without the user having to explicitly configure something. It’s sad that boot makes that impossible 😦