Skip to content

Commit

Permalink
Support Tomcat 9 and Undertow 2
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jun 28, 2018
1 parent b4cd4f4 commit 45fdf2f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 26 deletions.
6 changes: 3 additions & 3 deletions spring-boot-project/spring-boot-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 11 additions & 9 deletions spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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:

Expand Down Expand Up @@ -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"]
----
Expand All @@ -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]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
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();
Expand Down Expand Up @@ -263,7 +263,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
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();
Expand Down Expand Up @@ -314,7 +314,7 @@ protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
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;
Expand Down Expand Up @@ -181,8 +180,7 @@ public void tomcatAdditionalConnectors() {
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);
Expand Down
1 change: 1 addition & 0 deletions spring-boot-samples/spring-boot-sample-jetty-jsp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
1 change: 1 addition & 0 deletions spring-boot-samples/spring-boot-sample-jetty-ssl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
1 change: 1 addition & 0 deletions spring-boot-samples/spring-boot-sample-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down

0 comments on commit 45fdf2f

Please sign in to comment.