0

I'm trying to configure my Scalatra application according documentation, but I can't run. I have such a code for bootstrap file

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/*")
  }
}

and all I see in output is

> 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

What should I do to run this bootstrap file? Scalatra version is 2.4.0-RC2-2

Dmitry Meshkov
  • 921
  • 7
  • 20
  • I think [scalatra-website-examples](https://github.com/scalatra/scalatra-website-examples) is usuful. There is a example for [v2.4](https://github.com/scalatra/scalatra-website-examples/tree/master/2.4/http/scalatra-http-demo). And I think there is difference between your code and example code. Please tell me more detailed information. – hiropon Jul 24 '15 at 14:57
  • As you noted in answer, their 2.4.0 examples use 2.3.0 version – Dmitry Meshkov Jul 24 '15 at 15:32

1 Answers1

0

I compiled and made it working scalatra-website-examples/2.4/http/scalatra-http-demo/

My configuration is like below:

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 !

And this is my logging output:

> 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

Your log doesn't show ScalatraListener, perhaps web.xml doesn't exist.

hiropon
  • 1,675
  • 2
  • 18
  • 41