@Override
        protected void configure(ServerBuilder sb) throws Exception {
            sb.http(0);
            sb.https(0);
            sb.tlsSelfSigned();
            sb.requestTimeoutMillis(0);

            sb.serviceUnder(
                    "/jsp/",
                    JettyService.builder()
                                .handler(newWebAppContext())
                                .customizer(s -> jettyBeans.addAll(s.getBeans()))
                                .build()
                                .decorate(LoggingService.newDecorator()));

            sb.serviceUnder(
                    "/default/",
                    JettyService.builder()
                                .handler(new DefaultHandler())
                                .build());

            final ResourceHandler resourceHandler = new ResourceHandler();
            resourceHandler.setBaseResourceAsString(webAppRoot().getPath());
            sb.serviceUnder(
                    "/resources/",
                    JettyService.builder()
                                .handler(resourceHandler)
                                .build());

            sb.service(
                    "/headers-only",
                    newJettyService((req, res, callback) -> {
                        res.setStatus(204);
                        res.getHeaders().add("x-headers", "foo");
                        callback.succeeded();
                        return true;
                    }));

            sb.service(
                    "/headers-trailers",
                    newJettyService((req, res, callback) -> {
                        res.setStatus(200);
                        res.getHeaders().add("x-headers", "bar");
                        res.setTrailersSupplier(() -> HttpFields.from(new HttpField("x-trailers", "baz")));
                        callback.succeeded();
                        return true;
                    }));

            sb.service("/headers-data-trailers",
                       newJettyService((req, res, callback) -> {
                           res.setStatus(200);
                           res.getHeaders().add("x-headers", "bar");
                           res.setTrailersSupplier(() -> HttpFields.from(new HttpField("x-trailers", "baz")));
                           res.write(true, ByteBuffer.wrap("qux".getBytes()), callback);
                           return true;
                       }));

            // Attempts to write after the request handling is completed due to timeout or disconnection,
            // and captures the exception raised by {@link ServletOutputStream#println()}.
            sb.service("/timeout/{timeout}",
                       newJettyService((req, res, callback) -> {
                           final ServiceRequestContext ctx = ServiceRequestContext.current();
                           ctx.setRequestTimeoutMillis(Integer.parseInt(ctx.pathParam("timeout")));
                           res.setStatus(200);
                           await().until(() -> ctx.log().isComplete());
                           try {
                               res.write(true, ByteBuffer.wrap(System.lineSeparator().getBytes()), callback);
                               capturedException.set(NO_EXCEPTION);
                           } catch (Throwable cause) {
                               capturedException.set(cause);
                           }
                           return true;
                       }));

            // Attempts to write again after closing the output stream,
            // and captures the exception raised by the failed write attempt after close().
            sb.service("/write-after-completion",
                       newJettyService((req, res, callback) -> {
                           res.setStatus(200);
                           res.write(true, ByteBuffer.wrap("before close".getBytes()), callback);
                           res.write(true, ByteBuffer.wrap("after close".getBytes()), new Callback() {
                               @Override
                               public void succeeded() {
                                   capturedException.set(NO_EXCEPTION);
                               }

                               @Override
                               public void failed(Throwable x) {
                                   capturedException.set(x);
                               }
                           });
                           return true;
                       }));

            sb.service("/stream/{totalSize}/{chunkSize}",
                       newJettyService(new AsyncStreamingHandlerFunction()));

            sb.service("/throwing",
                       newJettyService((req, res, callback) -> {
                           callback.succeeded();
                           return true;
                       }).decorate((delegate, ctx, req) -> {
                           ctx = spy(ctx);
                           // relies on the fact that JettyService calls this method
                           when(ctx.sessionProtocol()).thenThrow(RUNTIME_EXCEPTION);
                           return delegate.serve(ctx, req);
                       }));
        }
Captures the exception raised in a Jetty handler block.
jetty/jetty12/src/test/java/com/linecorp/armeria/server/jetty/JettyServiceTest.java