I dont understand how i can rewrite this code used with jetty 6 for jetty 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"});
//root.addServlet(new ServletHolder(new TestServlet()), "/test");
server.setHandlers(new Handler[]{root});
try {
server.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
The code above works fine and response the static content from the web folder and servlets, mapped in web.xml. Here is my attempts to use embeded jetty 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 is starting, but index.html request throws error:
"java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.isAsyncStarted()Z"
I tried to find a working example in Google, but found nothing useful. Official samples and documentation is very confusing and I do not understand how i can use embeded jetty version 9.