Skip to content

Commit 45fdf2f

Browse files
committed
Support Tomcat 9 and Undertow 2
Closes gh-11749 Closes gh-12243
1 parent b4cd4f4 commit 45fdf2f

File tree

11 files changed

+30
-26
lines changed

11 files changed

+30
-26
lines changed

spring-boot-project/spring-boot-dependencies/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
<selenium.version>3.9.1</selenium.version>
148148
<selenium-htmlunit.version>2.29.3</selenium-htmlunit.version>
149149
<sendgrid.version>4.1.2</sendgrid.version>
150-
<servlet-api.version>3.1.0</servlet-api.version>
150+
<servlet-api.version>4.0.1</servlet-api.version>
151151
<slf4j.version>1.7.25</slf4j.version>
152152
<snakeyaml.version>1.19</snakeyaml.version>
153153
<solr.version>7.2.1</solr.version>
@@ -175,9 +175,9 @@
175175
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
176176
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
177177
<thymeleaf-extras-java8time.version>3.0.1.RELEASE</thymeleaf-extras-java8time.version>
178-
<tomcat.version>8.5.31</tomcat.version>
178+
<tomcat.version>9.0.10</tomcat.version>
179179
<unboundid-ldapsdk.version>4.0.6</unboundid-ldapsdk.version>
180-
<undertow.version>1.4.25.Final</undertow.version>
180+
<undertow.version>2.0.9.Final</undertow.version>
181181
<webjars-hal-browser.version>3325375</webjars-hal-browser.version>
182182
<webjars-locator-core.version>0.35</webjars-locator-core.version>
183183
<wsdl4j.version>1.6.3</wsdl4j.version>

spring-boot-project/spring-boot-docs/src/main/asciidoc/getting-started.adoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ Spring Boot supports the following embedded servlet containers:
5151
|===
5252
|Name |Servlet Version
5353

54-
|Tomcat 8.5
55-
|3.1
54+
|Tomcat 9.0
55+
|4.0
5656

5757
|Jetty 9.4
5858
|3.1
5959

60-
|Undertow 1.4
61-
|3.1
60+
|Undertow 2.0
61+
|4.0
6262
|===
6363

6464
You can also deploy Spring Boot applications to any Servlet 3.1+ compatible container.

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

+11-9
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ The following Maven example shows how to exclude Tomcat and include Jetty for Sp
523523

524524
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
525525
----
526+
<properties>
527+
<servlet-api.version>3.1.0</servlet-api.version>
528+
</properties>
526529
<dependency>
527530
<groupId>org.springframework.boot</groupId>
528531
<artifactId>spring-boot-starter-web</artifactId>
@@ -541,6 +544,9 @@ The following Maven example shows how to exclude Tomcat and include Jetty for Sp
541544
</dependency>
542545
----
543546

547+
NOTE: The version of the Servlet API has been overridden as, unlike Tomcat 9 and Undertow
548+
2.0, Jetty 9.4 does not support Servlet 4.0.
549+
544550
The following Gradle example shows how to exclude Netty and include Undertow for Spring
545551
WebFlux:
546552

@@ -727,16 +733,16 @@ To enable that support, your application needs to have two additional dependenci
727733

728734
[[howto-configure-http2-tomcat]]
729735
==== HTTP/2 with Tomcat
730-
Spring Boot ships by default with Tomcat 8.5.x. With that version, HTTP/2 is only
731-
supported if the `libtcnative` library and its dependencies are installed on the host
732-
operating system.
736+
Spring Boot ships by default with Tomcat 9.0.x which supports HTTP/2 out of the box when
737+
using JDK 9 or later. Alternatively, HTTP/2 can be used on JDK 8 if the `libtcnative`
738+
library and its dependencies are installed on the host operating system.
733739

734740
The library folder must be made available, if not already, to the JVM library path. You
735741
can do so with a JVM argument such as
736742
`-Djava.library.path=/usr/local/opt/tomcat-native/lib`. More on this in the
737-
https://tomcat.apache.org/tomcat-8.5-doc/apr.html[official Tomcat documentation].
743+
https://tomcat.apache.org/tomcat-9.0-doc/apr.html[official Tomcat documentation].
738744

739-
Starting Tomcat 8.5.x without that native support logs the following error:
745+
Starting Tomcat 9.0.x on JDK 8 without that native support logs the following error:
740746

741747
[indent=0,subs="attributes"]
742748
----
@@ -745,10 +751,6 @@ Starting Tomcat 8.5.x without that native support logs the following error:
745751

746752
This error is not fatal, and the application still starts with HTTP/1.1 SSL support.
747753

748-
Running your application with Tomcat 9.0.x and JDK9 does not require any native library to
749-
be installed. To use Tomcat 9, you can override the `tomcat.version` build property with
750-
the version of your choice.
751-
752754

753755

754756
[[howto-configure-webserver]]

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7409,9 +7409,9 @@ include::{test-examples}/web/client/SampleWebClientTests.java[tag=test]
74097409

74107410
[[boot-features-websockets]]
74117411
== WebSockets
7412-
Spring Boot provides WebSockets auto-configuration for embedded Tomcat 8.5, Jetty
7413-
9, and Undertow. If you deploy a war file to a standalone container, Spring Boot assumes
7414-
that the container is responsible for the configuration of its WebSocket support.
7412+
Spring Boot provides WebSockets auto-configuration for embedded Tomcat, Jetty, and
7413+
Undertow. If you deploy a war file to a standalone container, Spring Boot assumes that the
7414+
container is responsible for the configuration of its WebSocket support.
74157415

74167416
Spring Framework provides {spring-reference}web.html#websocket[rich WebSocket support]
74177417
that can be easily accessed through the `spring-boot-starter-websocket` module.

spring-boot-project/spring-boot-starters/spring-boot-starter-jetty/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
alternative to spring-boot-starter-tomcat</description>
1414
<properties>
1515
<main.basedir>${basedir}/../../..</main.basedir>
16+
<servlet-api.version>3.1.0</servlet-api.version>
1617
</properties>
1718
<dependencies>
1819
<dependency>

spring-boot-project/spring-boot-starters/spring-boot-starter-undertow/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<exclusions>
2626
<exclusion>
2727
<groupId>org.jboss.spec.javax.servlet</groupId>
28-
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
28+
<artifactId>jboss-servlet-api_4.0_spec</artifactId>
2929
</exclusion>
3030
</exclusions>
3131
</dependency>

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
230230
super.verifyZipEntries(verifier);
231231
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-context");
232232
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-core");
233-
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-3");
233+
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-4");
234234
assertThat(verifier
235235
.hasEntry("org/springframework/boot/loader/JarLauncher.class"))
236236
.as("Unpacked launcher classes").isTrue();
@@ -263,7 +263,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
263263
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-context");
264264
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-core");
265265
verifier.assertHasEntryNameStartingWith(
266-
"WEB-INF/lib-provided/javax.servlet-api-3");
266+
"WEB-INF/lib-provided/javax.servlet-api-4");
267267
assertThat(verifier
268268
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
269269
.as("Unpacked launcher classes").isTrue();
@@ -314,7 +314,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
314314
super.verifyZipEntries(verifier);
315315
verifier.assertHasEntryNameStartingWith("lib/spring-context");
316316
verifier.assertHasEntryNameStartingWith("lib/spring-core");
317-
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api-3");
317+
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api");
318318
assertThat(verifier
319319
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
320320
.as("Unpacked launcher classes").isFalse();

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import static org.assertj.core.api.Assertions.assertThat;
6464
import static org.junit.Assert.fail;
6565
import static org.mockito.ArgumentMatchers.any;
66-
import static org.mockito.BDDMockito.given;
6766
import static org.mockito.Mockito.inOrder;
6867
import static org.mockito.Mockito.mock;
6968
import static org.mockito.Mockito.verify;
@@ -181,8 +180,7 @@ public void tomcatAdditionalConnectors() {
181180
TomcatServletWebServerFactory factory = getFactory();
182181
Connector[] listeners = new Connector[4];
183182
for (int i = 0; i < listeners.length; i++) {
184-
Connector connector = mock(Connector.class);
185-
given(connector.getState()).willReturn(LifecycleState.STOPPED);
183+
Connector connector = new Connector();
186184
listeners[i] = connector;
187185
}
188186
factory.addAdditionalTomcatConnectors(listeners);

spring-boot-samples/spring-boot-sample-jetty-jsp/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<properties>
1616
<main.basedir>${basedir}/../..</main.basedir>
1717
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
18+
<servlet-api.version>3.1.0</servlet-api.version>
1819
</properties>
1920
<dependencies>
2021
<!-- Compile -->

spring-boot-samples/spring-boot-sample-jetty-ssl/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<description>Spring Boot Jetty SSL Sample</description>
1414
<properties>
1515
<main.basedir>${basedir}/../..</main.basedir>
16+
<servlet-api.version>3.1.0</servlet-api.version>
1617
</properties>
1718
<dependencies>
1819
<!-- Compile -->

spring-boot-samples/spring-boot-sample-jetty/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<description>Spring Boot Jetty Sample</description>
1414
<properties>
1515
<main.basedir>${basedir}/../..</main.basedir>
16+
<servlet-api.version>3.1.0</servlet-api.version>
1617
</properties>
1718
<dependencies>
1819
<!-- Compile -->

0 commit comments

Comments
 (0)