我正在尝试使用此处的示例从 Jetty 7 升级到 Jetty 9:
http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html#d0e18177
Server server = new Server(8080);
ServletContextHandler context=new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
HttpServlet servlet=new TestServlet();
context.addServlet(new ServletHolder(servlet), "/*");
server.setHandler(context);
server.start();
server.join();
但是,它在运行时死亡:
java.lang.NullPointerException
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:304)
at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:213)
at org.eclipse.jetty.server.Server.<init>(Server.java:128)
at org.eclipse.jetty.server.Server.<init>(Server.java:103)
示例中的 servlet 是一个简单的 hello world 示例。