The Spray-template jetty example comes with a web.xml configuration. If embedded is more your style, this is the way to go (Jetty 8.1.7):

package com.example
import spray.servlet.Servlet30ConnectorServlet
import spray.servlet.Initializer
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.bio.SocketConnector
import org.eclipse.jetty.webapp.WebAppContext
import org.eclipse.jetty.servlet.ServletContextHandler
object JettyServer {
def main(args : Array[String]) : Unit = {
start()
}
def start() {
try {
val server = new Server()
val connector = new SocketConnector();
connector.setPort(8080);
val context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
context.addEventListener(new Initializer());
val servletHolder = context.addServlet(classOf[Servlet30ConnectorServlet].getName(), "/*");
server.setConnectors(Array(connector));
server.start();
} catch {
case e:Throwable => e.printStackTrace();
}
}
}
view raw gistfile1.scala hosted with ❤ by GitHub


One Comment