Skip to content

Instantly share code, notes, and snippets.

@isterin
Created March 11, 2014 17:19
Show Gist options
  • Save isterin/9490550 to your computer and use it in GitHub Desktop.
Save isterin/9490550 to your computer and use it in GitHub Desktop.
Scalatra jetty 9.1.3 issue with standalone deployment
object Runner {
// this is my entry object as specified in sbt project definition
def main(args: Array[String]) {
val port = if (System.getenv("PORT") != null) System.getenv("PORT").toInt else 8080
val server = new Server(port)
val context = new WebAppContext()
context setContextPath "/"
context.setResourceBase("src/main/webapp")
context.addEventListener(new ScalatraListener)
context.addServlet(classOf[DefaultServlet], "/")
server.setHandler(context)
server.start()
server.join()
}
}
class SearchResource(private val searchService: SearchServiceInterface) extends ScalatraServlet with FutureSupport {
protected implicit def executor: ExecutionContext = GlobalContext.system.dispatcher
protected implicit def jsonFormats: Formats = DefaultFormats
get("/") {
new AsyncResult {
val is = Future {
val prom = Promise[String]()
new Thread {
Thread.sleep(500)
prom.success("SUCCESS")
}
Ok(Await.result(prom.future, 10 seconds))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment