This updates Jetty to the latest 9.x version as of writing. The 9.x is still running on Java 8. The update needs two code changes. `SessionManager` was replaced with `SessionHandler`. This was documented in the Jetty documentation. Adding the `GitblitContext` to the `WebAppContext` will result in two instances getting created, because the code was changed that prevents instantiation the same listener class multiple times. (The second time is when the web.xml is read.) Instead, it must be added to the servlet handler of the `WebAppContext`. This results in properly adhering to the changed internal startup flow. Updating Jetty also resolves #1409.pull/1438/head
<classpathentry kind="lib" path="ext/javax.mail-1.5.6.jar" sourcepath="ext/src/javax.mail-1.5.6.jar" /> | <classpathentry kind="lib" path="ext/javax.mail-1.5.6.jar" sourcepath="ext/src/javax.mail-1.5.6.jar" /> | ||||
<classpathentry kind="lib" path="ext/activation-1.1.jar" sourcepath="ext/src/activation-1.1.jar" /> | <classpathentry kind="lib" path="ext/activation-1.1.jar" sourcepath="ext/src/activation-1.1.jar" /> | ||||
<classpathentry kind="lib" path="ext/javax.servlet-api-3.1.0.jar" sourcepath="ext/src/javax.servlet-api-3.1.0.jar" /> | <classpathentry kind="lib" path="ext/javax.servlet-api-3.1.0.jar" sourcepath="ext/src/javax.servlet-api-3.1.0.jar" /> | ||||
<classpathentry kind="lib" path="ext/jetty-servlet-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-servlet-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-security-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-security-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-server-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-server-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-continuation-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-continuation-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-http-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-http-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-io-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-io-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-util-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-util-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-webapp-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-webapp-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-xml-9.3.16.v20170120.jar" sourcepath="ext/src/jetty-xml-9.3.16.v20170120.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-servlet-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-servlet-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-security-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-security-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-server-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-server-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-continuation-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-continuation-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-http-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-http-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-io-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-io-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-util-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-util-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-webapp-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-webapp-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/jetty-xml-9.4.49.v20220914.jar" sourcepath="ext/src/jetty-xml-9.4.49.v20220914.jar" /> | |||||
<classpathentry kind="lib" path="ext/wicket-1.4.22.jar" sourcepath="ext/src/wicket-1.4.22.jar" /> | <classpathentry kind="lib" path="ext/wicket-1.4.22.jar" sourcepath="ext/src/wicket-1.4.22.jar" /> | ||||
<classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.22.jar" sourcepath="ext/src/wicket-auth-roles-1.4.22.jar" /> | <classpathentry kind="lib" path="ext/wicket-auth-roles-1.4.22.jar" sourcepath="ext/src/wicket-auth-roles-1.4.22.jar" /> | ||||
<classpathentry kind="lib" path="ext/wicket-extensions-1.4.22.jar" sourcepath="ext/src/wicket-extensions-1.4.22.jar" /> | <classpathentry kind="lib" path="ext/wicket-extensions-1.4.22.jar" sourcepath="ext/src/wicket-extensions-1.4.22.jar" /> |
# Convenience properties for dependencies | # Convenience properties for dependencies | ||||
properties: { | properties: { | ||||
jetty.version : 9.3.16.v20170120 | |||||
jetty.version : 9.4.49.v20220914 | |||||
slf4j.version : 1.7.29 | slf4j.version : 1.7.29 | ||||
wicket.version : 1.4.22 | wicket.version : 1.4.22 | ||||
lucene.version : 5.5.2 | lucene.version : 5.5.2 |
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-servlet-9.3.16.v20170120.jar"> | |||||
<library name="jetty-servlet-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-servlet-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-servlet-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-servlet-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-servlet-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-security-9.3.16.v20170120.jar"> | |||||
<library name="jetty-security-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-security-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-security-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-security-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-security-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-server-9.3.16.v20170120.jar"> | |||||
<library name="jetty-server-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-server-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-server-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-server-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-server-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-continuation-9.3.16.v20170120.jar"> | |||||
<library name="jetty-continuation-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-continuation-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-continuation-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-continuation-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-continuation-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-http-9.3.16.v20170120.jar"> | |||||
<library name="jetty-http-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-http-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-http-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-http-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-http-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-io-9.3.16.v20170120.jar"> | |||||
<library name="jetty-io-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-io-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-io-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-io-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-io-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-util-9.3.16.v20170120.jar"> | |||||
<library name="jetty-util-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-util-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-util-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-util-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-util-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-webapp-9.3.16.v20170120.jar"> | |||||
<library name="jetty-webapp-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-webapp-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-webapp-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-webapp-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-webapp-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> | ||||
<orderEntry type="module-library"> | <orderEntry type="module-library"> | ||||
<library name="jetty-xml-9.3.16.v20170120.jar"> | |||||
<library name="jetty-xml-9.4.49.v20220914.jar"> | |||||
<CLASSES> | <CLASSES> | ||||
<root url="jar://$MODULE_DIR$/ext/jetty-xml-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/jetty-xml-9.4.49.v20220914.jar!/" /> | |||||
</CLASSES> | </CLASSES> | ||||
<JAVADOC /> | <JAVADOC /> | ||||
<SOURCES> | <SOURCES> | ||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-xml-9.3.16.v20170120.jar!/" /> | |||||
<root url="jar://$MODULE_DIR$/ext/src/jetty-xml-9.4.49.v20220914.jar!/" /> | |||||
</SOURCES> | </SOURCES> | ||||
</library> | </library> | ||||
</orderEntry> | </orderEntry> |
import org.eclipse.jetty.server.HttpConnectionFactory; | import org.eclipse.jetty.server.HttpConnectionFactory; | ||||
import org.eclipse.jetty.server.Server; | import org.eclipse.jetty.server.Server; | ||||
import org.eclipse.jetty.server.ServerConnector; | import org.eclipse.jetty.server.ServerConnector; | ||||
import org.eclipse.jetty.server.session.HashSessionManager; | |||||
import org.eclipse.jetty.server.session.SessionHandler; | |||||
import org.eclipse.jetty.servlet.ListenerHolder; | |||||
import org.eclipse.jetty.util.security.Constraint; | import org.eclipse.jetty.util.security.Constraint; | ||||
import org.eclipse.jetty.util.thread.QueuedThreadPool; | import org.eclipse.jetty.util.thread.QueuedThreadPool; | ||||
import org.eclipse.jetty.webapp.WebAppContext; | import org.eclipse.jetty.webapp.WebAppContext; | ||||
} | } | ||||
ServerConnector connector = new ServerConnector(server, factory); | ServerConnector connector = new ServerConnector(server, factory); | ||||
connector.setSoLingerTime(-1); | |||||
connector.setIdleTimeout(settings.getLong(Keys.server.httpIdleTimeout, 30000L)); | connector.setIdleTimeout(settings.getLong(Keys.server.httpIdleTimeout, 30000L)); | ||||
connector.setPort(params.securePort); | connector.setPort(params.securePort); | ||||
String bindInterface = settings.getString(Keys.server.httpsBindInterface, null); | String bindInterface = settings.getString(Keys.server.httpsBindInterface, null); | ||||
httpConfig.setSendDateHeader(false); | httpConfig.setSendDateHeader(false); | ||||
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); | ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); | ||||
connector.setSoLingerTime(-1); | |||||
connector.setIdleTimeout(settings.getLong(Keys.server.httpIdleTimeout, 30000L)); | connector.setIdleTimeout(settings.getLong(Keys.server.httpIdleTimeout, 30000L)); | ||||
connector.setPort(params.port); | connector.setPort(params.port); | ||||
String bindInterface = settings.getString(Keys.server.httpBindInterface, null); | String bindInterface = settings.getString(Keys.server.httpBindInterface, null); | ||||
rootContext.setWar(location.toExternalForm()); | rootContext.setWar(location.toExternalForm()); | ||||
rootContext.setTempDirectory(tempDir); | rootContext.setTempDirectory(tempDir); | ||||
// Set cookies HttpOnly so they are not accessible to JavaScript engines | // Set cookies HttpOnly so they are not accessible to JavaScript engines | ||||
HashSessionManager sessionManager = new HashSessionManager(); | |||||
sessionManager.setHttpOnly(true); | |||||
SessionHandler sessionHandler = rootContext.getSessionHandler(); | |||||
sessionHandler.setHttpOnly(true); | |||||
// Use secure cookies if only serving https | // Use secure cookies if only serving https | ||||
sessionManager.setSecureRequestOnly( (params.port <= 0 && params.securePort > 0) || | |||||
(params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) ); | |||||
rootContext.getSessionHandler().setSessionManager(sessionManager); | |||||
sessionHandler.setSecureRequestOnly( (params.port <= 0 && params.securePort > 0) || | |||||
(params.port > 0 && params.securePort > 0 && settings.getBoolean(Keys.server.redirectToHttpsPort, true)) ); | |||||
// Ensure there is a defined User Service | // Ensure there is a defined User Service | ||||
String realmUsers = params.userService; | String realmUsers = params.userService; | ||||
} | } | ||||
// Setup the Gitblit context | // Setup the Gitblit context | ||||
GitblitContext gitblit = newGitblit(settings, baseFolder); | |||||
rootContext.addEventListener(gitblit); | |||||
ListenerHolder gitblitHolder = new ListenerHolder(GitblitContext.class); | |||||
gitblitHolder.setListener(newGitblit(settings, baseFolder)); | |||||
rootContext.getServletHandler().addListener(gitblitHolder); | |||||
try { | try { | ||||
// start the shutdown monitor | // start the shutdown monitor |