2011-07-19 66 views
4

我試圖在基於Scalatra的-sbt.g8如下:Scalate的ResourceNotFoundException在Scalatra的

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

,但我發現以下異常(即使該文件存在) - 任何線索? _baseResource==null

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的到來。

回答

5

從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")