scalatra

How to create executable single jar which include webapp resources by sbt-assembly with scalatra

你离开我真会死。 提交于 2020-02-24 09:29:12
问题 I'm making webapp using scalatra framework via sbt & xsbt-web-plugin. I want to package all resources(templates, css, js) into a single jar. In sbt with sbt-assembly plugin, assembly command makes single jar which includes all of project's dependencies. $ java -jar myproject.jar and I open it in browser Could not load resource: [/WEB-INF/views/index.scaml]; are you sure it's within [null]? I unzipped jar to confirm that it does not include src/main/webapp/* . How can I config sbt for

How to get sbt-assembly merge right?

旧街凉风 提交于 2020-01-24 09:39:33
问题 In our Scala/Scalatra project, we have this merge policy for the plugin sbt-assembly : assemblyMergeStrategy in assembly := { case x => val oldStrategy = (assemblyMergeStrategy in assembly).value oldStrategy(x) } [error] 11 errors were encountered during merge java.lang.RuntimeException: deduplicate: different file contents found in the following: ~/.ivy2/cache/org.scalatra/scalatra_2.11/jars/scalatra_2.11-2.3.1.jar:mime.types ~/.ivy2/cache/com.amazonaws/aws-java-sdk-s3/jars/aws-java-sdk-s3-1

Producing json in a Scala app using json4s

别说谁变了你拦得住时间么 提交于 2020-01-24 09:33:06
问题 I am attempting to produce JSON in a Scala app using json4s. Fairly straight forward, Here's some sample value I put together to test it in my Scalatra app: import org.json4s._ import org.json4s.JsonDSL._ object JsonStub { val getPeople = ("people" -> ("person_id" -> 5) ~ ("test_count" -> 5)) } In my controller, I simply have: import org.json4s._ import org.json4s.JsonDSL._ import org.json4s.{DefaultFormats, Formats} class FooController(mongoDb: MongoClient)(implicit val swagger: Swagger)

Tilde in Scala found in Scalatra example code

六眼飞鱼酱① 提交于 2020-01-14 13:34:24
问题 Just ran into this sample code learning about Commands in Scalatra: protected def handle: Handler = { case c: CreateTodoCommand => add(newTodo(~c.name.value)) } In this particular case, what exactly is the relevance of ~ in ~c.name.value ? Not sure where to find more documentation on this particular symbol. 回答1: In Scala: ~x translates to x.unary_~ (this also applies to + , - and ! as explained in this post). So your example translates to: add(newTodo(c.name.value.unary_~)) The documentation

Declaring a different compile path for CoffeeScript

假装没事ソ 提交于 2019-12-22 18:45:37
问题 I have a Scalatra app that compiles CoffeeScript, using https://github.com/softprops/coffeescripted-sbt, to a default location, target/scala-2.9.1/resource_managed/main/js . I want to put the generated javascripts somewhere available to me publicly, in a folder called src/main/webapp/coffee , but the example given defaults to `/target/...' resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_ / "your_preference" / "js") My build.sbt: seq(coffeeSettings: _*) // doesn

How to keep sbt running (as a daemon process) after executing a command

巧了我就是萌 提交于 2019-12-22 09:24:23
问题 I want to launch scalatra server from sbt. How do I do that? The following does launch scalatra: sbt "container:start" But it exits immediately: [info] starting server ... [success] Total time: 2 s, completed Sep 12, 2015 2:39:32 PM > [info] waiting for server to shut down... Most preferably the whole thing would run in a nohup as a daemon process. 回答1: Don't do it on one line. Use two commands. ./sbt container:start 回答2: sbt "; <command>; console" does the trick. Note the initial semicolon

How to keep sbt running (as a daemon process) after executing a command

佐手、 提交于 2019-12-22 09:23:07
问题 I want to launch scalatra server from sbt. How do I do that? The following does launch scalatra: sbt "container:start" But it exits immediately: [info] starting server ... [success] Total time: 2 s, completed Sep 12, 2015 2:39:32 PM > [info] waiting for server to shut down... Most preferably the whole thing would run in a nohup as a daemon process. 回答1: Don't do it on one line. Use two commands. ./sbt container:start 回答2: sbt "; <command>; console" does the trick. Note the initial semicolon

How can one change the location of the “webapp” directory for a Scalatra application?

烂漫一生 提交于 2019-12-22 05:57:08
问题 By default, Scalatra expects the "webapp" directory to be at src/main/webapp . How could that be changed to, e.g., content/doc-root ? sbt allows for customizing its default directories using something like the following: scalaSource <<= (baseDirectory)(_ / "src") So I assume it's just a matter of knowing the right "configuration key" to use... 回答1: @Kelsey Gilmore-Innis has the right answer, but since it's not accepted let's break it, break it, break it down. First, I'm assuming you're

No multipartconfig for servlet error from Jetty using scalatra

佐手、 提交于 2019-12-22 04:07:46
问题 I am trying to unit test an upload call but I get this error for the following code: @MultipartConfig(maxFileSize = 3145728) class WebServlet extends ScalatraServlet with FileUploadSupport { override def isSizeConstraintException(e: Exception) = e match { case se: ServletException if se.getMessage.contains("exceeds max filesize") || se.getMessage.startsWith("Request exceeds maxRequestSize") => true case _ => false } error { case e: SizeConstraintExceededException => RequestEntityTooLarge("too

Error while posting data from angular js form

妖精的绣舞 提交于 2019-12-21 05:14:18
问题 I have an angularJS form which posts data to a scalatra servlet. When the form gets submitted I can't get any form params in my scalatra servlet. Below is my code AngularJS $scope.createUser = function() { $http.post('/createUser',{name:$scope.name,email:$scope.email,pwd:$scope.pwd}). success(function(data, status, headers, config) { alert("success " + data) }). error(function(data, status, headers, config) { alert("failure =>" +data) }); }; }); }; HTML form <form ng-controller=