I do not understand how I can rewrite this code used with berth 6 for berth 9:
import org.mortbay.jetty.*; import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.webapp.WebAppContext; public class ApplLauncher { public static void main(String[] args) { Server server = new Server(); Connector connector = new SelectChannelConnector(); connector.setPort(8080); server.addConnector(connector); WebAppContext root = new WebAppContext("C:\\Users\\OZKA\\IdeaProjects\\projectname\\projectname\\web", "/"); root.setWelcomeFiles(new String[]{"index.html"});
The above code works fine and responds to static content from a web folder and servlets displayed in web.xml. Here are my attempts to use the built-in pier 9:
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.Handler; public class ApplLauncher { public static void main(String[] args) { System.out.println("Hello from ScalaSbt Web Project"); Server server = new Server(8080); WebAppContext webapp = new WebAppContext("D:\\Dev\\Scala\\ScalaTestProject\\web\\", "/"); ResourceHandler resource_handler = new ResourceHandler(); resource_handler.setWelcomeFiles(new String[]{ "index.html" }); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { resource_handler, webapp}); server.setHandler(handlers); try { server.start(); server.join(); } catch(Exception ex) { ex.printStackTrace(); } } }
The server starts, but index.html asks for an error:
"java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z"
I tried to find a working example on Google, but did not find anything useful. The official samples and documentation are very confusing, and I donβt understand how I can use the built-in version of berth 9.
source share