ScalatraBootstrap不会运行

时间:2015-07-24 11:26:34

标签: scala scalatra

我试图根据documentation配置我的Scalatra应用程序,但我无法运行。 我有一个用于bootstrap文件的代码

import javax.servlet.ServletContext

import org.scalatra._
import org.scalatra.example.UserController

class ScalatraBootstrap extends LifeCycle {

  override def init(context: ServletContext) {
    println("!!!!!!!!!!!!!!!!!!!")
    context.mount(new UserController, "/user/*")
  }
}

我在输出中看到的只是

> container:start
[info] starting server ...
[success] Total time: 1 s, completed 24.07.2015 14:24:40
> 2015-07-24 14:24:40.907:INFO::main: Logging initialized @86ms
2015-07-24 14:24:40.913:INFO:oejr.Runner:main: Runner
2015-07-24 14:24:40.978:INFO:oejs.Server:main: jetty-9.2.1.v20140609
2015-07-24 14:24:42.472:WARN:oeja.AnnotationConfiguration:main: ServletContainerInitializers: detected. Class hierarchy: empty
2015-07-24 14:24:42.665:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@12bc6874{/,file:/D:/code/scala/scalatra/scalatra-aut
h/target/webapp/,AVAILABLE}{file:/D:/code/scala/scalatra/scalatra-auth/target/webapp/}
2015-07-24 14:24:42.666:WARN:oejsh.RequestLogHandler:main: !RequestLog
2015-07-24 14:24:42.721:INFO:oejs.ServerConnector:main: Started ServerConnector@30b8a058{HTTP/1.1}{0.0.0.0:8080}
2015-07-24 14:24:42.721:INFO:oejs.Server:main: Started @1918ms

如何运行此引导程序文件? Scalatra版本是2.4.0-RC2-2

1 个答案:

答案 0 :(得分:0)

我编译并使其正常工作scalatra-website-examples/2.4/http/scalatra-http-demo/

我的配置如下:

build.scala

object ScalatraHttpDemoBuild extends Build {
  val Organization = "org.scalatra"
  val Name = "Scalatra HTTP Demo"
  val Version = "0.1.0-SNAPSHOT"
  val ScalaVersion = "2.11.1"
- val ScalatraVersion = "2.3.0"       // delete !
+ val ScalatraVersion = "2.4.0-RC2-2" // add !

这是我的日志输出:

> container:start
[info] Compiling Templates in Template Directory: /home/foobar/git/scalatra-website-examples/2.4/http/scalatra-http-demo/src/main/webapp/WEB-INF/templates
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Compiling 1 Scala source to /home/foobar/git/scalatra-website-examples/2.4/http/scalatra-http-demo/target/scala-2.11/classes...
2015-07-25 00:06:56.676:INFO:oejs.Server:jetty-8.1.8.v20121106
2015-07-25 00:06:56.820:INFO:oejw.StandardDescriptorProcessor:NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
Null identity service, trying login service: null
Finding identity service: null
2015-07-25 00:06:57.253:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,[file:/home/foobar/git/scalatra-website-examples/2.4/http/scalatra-http-demo/src/main/webapp/]}
2015-07-25 00:06:57.253:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,[file:/home/foobar/git/scalatra-website-examples/2.4/http/scalatra-http-demo/src/main/webapp/]}
00:06:57.294 [pool-7-thread-3] INFO  o.scalatra.servlet.ScalatraListener - The cycle class name from the config: ScalatraBootstrap
00:06:57.431 [pool-7-thread-3] INFO  o.scalatra.servlet.ScalatraListener - Initializing life cycle class: ScalatraBootstrap
test!!!
2015-07-25 00:06:57.565:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,[file:/home/foobar/git/scalatra-website-examples/2.4/http/scalatra-http-demo/src/main/webapp/]}
00:06:57.995 [pool-7-thread-3] INFO  o.f.s.servlet.ServletTemplateEngine - Scalate template engine using working directory: /tmp/scalate-6206025487365596923-workdir
2015-07-25 00:06:58.027:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
[success] Total time: 9 s, completed 2015/07/25 0:06:58

您的日志未显示ScalatraListener,可能web.xml不存在。