jetty.project
jetty.project copied to clipboard
Fallback to server-level ErrorHandler broken for EE8-9 apps
Jetty version(s) 12.1.3
Jetty Environment ee8, ee9
Java version/vendor (use: java -version)
21
Description
The ability to set a single ErrorHandler on the Server and have it work for ee8 and ee9 applications doesn't work. There are 2 reasons for this:
- The
WebAppContexttries hard to make sure anErrorHandleris set at the context level, even if you don't specify one. You can set it tonullpost-construction but... - The code that tries to fallback to the Server-level handler in
ErrorHandler.getErrorHandler()doesn't work because it tries to get an ee8ErrorHandlerfrom the server:
public static ErrorHandler getErrorHandler(Server server, ContextHandler context) {
ErrorHandler errorHandler = null;
if (context != null)
errorHandler = context.getErrorHandler();
if (errorHandler == null && server != null)
errorHandler = server.getBean(ErrorHandler.class); // <- EE8 ErrorHandler
return errorHandler;
}
Also, it's worth pointing out that the ee8-9 versions of ErrorHandler do not extend the core one like the ee10-11 do. The net effect of this is that we have to have 2 separate implementations of our custom handler to make sure it's used in all cases. Relevant mailing list thread: https://www.eclipse.org/lists/jetty-users/msg10938.html