4

I'm trying the following based on scalatra-sbt.g8:

class FooWeb extends ScalatraServlet with ScalateSupport {
  beforeAll { contentType = "text/html" }
  get("/") {
    templateEngine.layout("/WEB-INF/scalate/templates/hello-scalate.jade")
  }
}

but I'm getting the following exception (even though the file exists) - any clues?

Could not load resource: [/WEB-INF/scalate/templates/hello-scalate.jade]; are you sure it's within [null]?

org.fusesource.scalate.util.ResourceNotFoundException: Could not load resource: [/WEB-INF/scalate/templates/hello-scalate.jade]; are you sure it's within [null]?

FWIW, the innermost exception is coming from org.mortbay.jetty.handler.ContextHandler.getResource line 1142: _baseResource==null.

Yang
  • 16,037
  • 15
  • 100
  • 142

1 Answers1

5

Got an answer from the scalatra mailing list. The problem was that I was starting the Jetty server with:

import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.{Context,ServletHolder}
val server = new Server(8080)
val root = new Context(server, "/", Context.SESSIONS)
root.addServlet(new ServletHolder(new FooWeb()), "/*")
server.start()

I needed to insert this before start():

root.setResourceBase("src/main/webapp")
Yang
  • 16,037
  • 15
  • 100
  • 142