slowr
slowr

Reputation: 54

Jetty Server blocks when setting handler

I am trying to setup a Jetty Server with Servlet Contexts and it blocks when calling server.setHandler(context). If I run the code snippet from below, which is actually following the example from http://www.eclipse.org/jetty/documentation/9.3.x/embedding-jetty.html#_embedding_servletcontexts , it only prints one "a" and then blocks.

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");

Server server = new Server(8070);
log.info("a");
server.setHandler(context);

log.info("a");
context.addServlet(EventServer.class, "/response");
context.addServlet(NotificationServer.class, "/notification");

log.info("a");
context.addEventListener(new ConfigureService());
context.addEventListener(new NotificationService());

try {
        server.start();
        log.info("Jetty-Server Started");
        server.join();
} catch (Exception e) {
        log.error(ExceptionUtils.getFullStackTrace(e));
} finally {
        server.destroy();
}

Any idea why it does not execute the rest of the code and blocks when setting the handler?

Upvotes: 0

Views: 214

Answers (1)

slowr
slowr

Reputation: 54

It turns out that you can't actually run the jetty-server and jetty-servlet while them being different versions and this will cause the block when setting the handler.

Upvotes: 0

Related Questions