How to start Lift in embedded Jetty?
Asked Answered
P

1

9

I have a server, which shall serve some web content as a part of it's duties. It was working using embedded Jetty, and I want to add some Lift's beauty to it (templates, actors, etc).

The problem is all lift examples use Jetty as a container. Is there a way to start Lift in my embedded Jetty? And if yes, how?

Prentice answered 25/12, 2011 at 6:28 Comment(0)
P
5

Found the answer: RunWebApp.scala

import _root_.org.mortbay.jetty.Connector
import _root_.org.mortbay.jetty.Server
import _root_.org.mortbay.jetty.webapp.WebAppContext
import org.mortbay.jetty.nio._

object RunWebApp extends Application {
  val server = new Server
  val scc = new SelectChannelConnector
  scc.setPort(8080)
  server.setConnectors(Array(scc))

  val context = new WebAppContext()
  context.setServer(server)
  context.setContextPath("/")
  context.setWar("src/main/webapp")

  server.addHandler(context)

  try {
    println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP")
    server.start()
    while (System.in.available() == 0) {
      Thread.sleep(5000)
    }
    server.stop()
    server.join()
  } catch {
    case exc : Exception => {
      exc.printStackTrace()
      System.exit(100)
    }
  }
}

My only problem now is to build this with Lift 2.4, Scala 2.9.1 and Eclipse Jetty - currently I can find only artifacts for Lift 2.3, Scala 2.8.1 and Mortbay Jetty.

Prentice answered 25/12, 2011 at 8:25 Comment(1)
If you go here liftweb.net/download , the sample zip file will let you get the latest lift jarVituperation

© 2022 - 2024 — McMap. All rights reserved.