Scalate ResourceNotFoundException в Скалатре - PullRequest
4 голосов
/ 19 июля 2011

Я пытаюсь сделать следующее на основе scalatra-sbt.g8:

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

, но получаю следующее исключение (даже если файл существует) - есть какие-нибудь подсказки?

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, самое внутреннее исключение исходит из org.mortbay.jetty.handler.ContextHandler.getResource строка 1142: _baseResource==null.

1 Ответ

5 голосов
/ 20 июля 2011

Получил ответ из списка рассылки scalatra. Проблема заключалась в том, что я запускал сервер Jetty с:

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()

Мне нужно было вставить это до start():

root.setResourceBase("src/main/webapp")
...