Commit 45fdf2ff authored by Andy Wilkinson's avatar Andy Wilkinson

Support Tomcat 9 and Undertow 2

Closes gh-11749
Closes gh-12243
parent b4cd4f4c
......@@ -147,7 +147,7 @@
<selenium.version>3.9.1</selenium.version>
<selenium-htmlunit.version>2.29.3</selenium-htmlunit.version>
<sendgrid.version>4.1.2</sendgrid.version>
<servlet-api.version>3.1.0</servlet-api.version>
<servlet-api.version>4.0.1</servlet-api.version>
<slf4j.version>1.7.25</slf4j.version>
<snakeyaml.version>1.19</snakeyaml.version>
<solr.version>7.2.1</solr.version>
......@@ -175,9 +175,9 @@
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
<thymeleaf-extras-java8time.version>3.0.1.RELEASE</thymeleaf-extras-java8time.version>
<tomcat.version>8.5.31</tomcat.version>
<tomcat.version>9.0.10</tomcat.version>
<unboundid-ldapsdk.version>4.0.6</unboundid-ldapsdk.version>
<undertow.version>1.4.25.Final</undertow.version>
<undertow.version>2.0.9.Final</undertow.version>
<webjars-hal-browser.version>3325375</webjars-hal-browser.version>
<webjars-locator-core.version>0.35</webjars-locator-core.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
......
......@@ -51,14 +51,14 @@ Spring Boot supports the following embedded servlet containers:
|===
|Name |Servlet Version
|Tomcat 8.5
|3.1
|Tomcat 9.0
|4.0
|Jetty 9.4
|3.1
|Undertow 1.4
|3.1
|Undertow 2.0
|4.0
|===
You can also deploy Spring Boot applications to any Servlet 3.1+ compatible container.
......
......@@ -523,6 +523,9 @@ The following Maven example shows how to exclude Tomcat and include Jetty for Sp
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
<properties>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......@@ -541,6 +544,9 @@ The following Maven example shows how to exclude Tomcat and include Jetty for Sp
</dependency>
----
NOTE: The version of the Servlet API has been overridden as, unlike Tomcat 9 and Undertow
2.0, Jetty 9.4 does not support Servlet 4.0.
The following Gradle example shows how to exclude Netty and include Undertow for Spring
WebFlux:
......@@ -727,16 +733,16 @@ To enable that support, your application needs to have two additional dependenci
[[howto-configure-http2-tomcat]]
==== HTTP/2 with Tomcat
Spring Boot ships by default with Tomcat 8.5.x. With that version, HTTP/2 is only
supported if the `libtcnative` library and its dependencies are installed on the host
operating system.
Spring Boot ships by default with Tomcat 9.0.x which supports HTTP/2 out of the box when
using JDK 9 or later. Alternatively, HTTP/2 can be used on JDK 8 if the `libtcnative`
library and its dependencies are installed on the host operating system.
The library folder must be made available, if not already, to the JVM library path. You
can do so with a JVM argument such as
`-Djava.library.path=/usr/local/opt/tomcat-native/lib`. More on this in the
https://tomcat.apache.org/tomcat-8.5-doc/apr.html[official Tomcat documentation].
https://tomcat.apache.org/tomcat-9.0-doc/apr.html[official Tomcat documentation].
Starting Tomcat 8.5.x without that native support logs the following error:
Starting Tomcat 9.0.x on JDK 8 without that native support logs the following error:
[indent=0,subs="attributes"]
----
......@@ -745,10 +751,6 @@ Starting Tomcat 8.5.x without that native support logs the following error:
This error is not fatal, and the application still starts with HTTP/1.1 SSL support.
Running your application with Tomcat 9.0.x and JDK9 does not require any native library to
be installed. To use Tomcat 9, you can override the `tomcat.version` build property with
the version of your choice.
[[howto-configure-webserver]]
......
......@@ -7409,9 +7409,9 @@ include::{test-examples}/web/client/SampleWebClientTests.java[tag=test]
[[boot-features-websockets]]
== WebSockets
Spring Boot provides WebSockets auto-configuration for embedded Tomcat 8.5, Jetty
9, and Undertow. If you deploy a war file to a standalone container, Spring Boot assumes
that the container is responsible for the configuration of its WebSocket support.
Spring Boot provides WebSockets auto-configuration for embedded Tomcat, Jetty, and
Undertow. If you deploy a war file to a standalone container, Spring Boot assumes that the
container is responsible for the configuration of its WebSocket support.
Spring Framework provides {spring-reference}web.html#websocket[rich WebSocket support]
that can be easily accessed through the `spring-boot-starter-websocket` module.
......
......@@ -13,6 +13,7 @@
alternative to spring-boot-starter-tomcat</description>
<properties>
<main.basedir>${basedir}/../../..</main.basedir>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependencies>
<dependency>
......
......@@ -25,7 +25,7 @@
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<artifactId>jboss-servlet-api_4.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
......
......@@ -230,7 +230,7 @@ public final class Verify {
super.verifyZipEntries(verifier);
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-context");
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-core");
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-3");
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-4");
assertThat(verifier
.hasEntry("org/springframework/boot/loader/JarLauncher.class"))
.as("Unpacked launcher classes").isTrue();
......@@ -263,7 +263,7 @@ public final class Verify {
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-context");
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-core");
verifier.assertHasEntryNameStartingWith(
"WEB-INF/lib-provided/javax.servlet-api-3");
"WEB-INF/lib-provided/javax.servlet-api-4");
assertThat(verifier
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
.as("Unpacked launcher classes").isTrue();
......@@ -314,7 +314,7 @@ public final class Verify {
super.verifyZipEntries(verifier);
verifier.assertHasEntryNameStartingWith("lib/spring-context");
verifier.assertHasEntryNameStartingWith("lib/spring-core");
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api-3");
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api");
assertThat(verifier
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
.as("Unpacked launcher classes").isFalse();
......
......@@ -63,7 +63,6 @@ import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
......@@ -181,8 +180,7 @@ public class TomcatServletWebServerFactoryTests
TomcatServletWebServerFactory factory = getFactory();
Connector[] listeners = new Connector[4];
for (int i = 0; i < listeners.length; i++) {
Connector connector = mock(Connector.class);
given(connector.getState()).willReturn(LifecycleState.STOPPED);
Connector connector = new Connector();
listeners[i] = connector;
}
factory.addAdditionalTomcatConnectors(listeners);
......
......@@ -15,6 +15,7 @@
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependencies>
<!-- Compile -->
......
......@@ -13,6 +13,7 @@
<description>Spring Boot Jetty SSL Sample</description>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependencies>
<!-- Compile -->
......
......@@ -13,6 +13,7 @@
<description>Spring Boot Jetty Sample</description>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<servlet-api.version>3.1.0</servlet-api.version>
</properties>
<dependencies>
<!-- Compile -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment