scalatra

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

僤鯓⒐⒋嵵緔 提交于 2019-12-05 08:49:51
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... Eugene Yokota @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 following Getting started guide to install Scalatra using g8 . Hopefully the same version I just got

No multipartconfig for servlet error from Jetty using scalatra

天大地大妈咪最大 提交于 2019-12-05 02:29:11
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 much!") } post("/uploadscript") { val privateParam = try {params("private") != null && params("private

Scala: print a stack trace in my Scalatra app

帅比萌擦擦* 提交于 2019-12-04 17:43:04
问题 Seems like a fairly straight forward problem, but I'd like to log a stack trace when my top level error handler in Scalatra is triggered. I'm intentionally throwing an exception in one of my methods by doing something as trivial as: throw new IllegalArgumentException In the error handler, the code looks like the following: error { case e => { val logger = LoggerFactory.getLogger(getClass) logger.info("an exception occurred: " + e.getStackTrace()) logger.info("the request body is: " + request)

Error while posting data from angular js form

强颜欢笑 提交于 2019-12-03 16:32:32
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="UserController"> <legend>Create User</legend> <label>Name</label> <input type="text" id="name" name="name" ng-model=

Scala: print a stack trace in my Scalatra app

南笙酒味 提交于 2019-12-03 11:32:46
Seems like a fairly straight forward problem, but I'd like to log a stack trace when my top level error handler in Scalatra is triggered. I'm intentionally throwing an exception in one of my methods by doing something as trivial as: throw new IllegalArgumentException In the error handler, the code looks like the following: error { case e => { val logger = LoggerFactory.getLogger(getClass) logger.info("an exception occurred: " + e.getStackTrace()) logger.info("the request body is: " + request) NotFound("An error occurred, please contact support") } } The error handler itself is Scalatra

Scala: Replace newline, tab and return sequences from string

独自空忆成欢 提交于 2019-12-03 10:46:32
I have a string of HTML that I'm copy pasting into a String object that looks something like the following: val s = """<body> <p>This is a test</p> <p>This is a test 2</p> </body""" The problem here is, when I display this string as JSON within the context of a web browser, the output displays literal \n and \t characters to the tune of something like this: "<body>\n <p>This is a test</p>\t <p>This is a test 2</p>\n</body>" Is it possible to perhaps strip all of these escaped sequences from my strings output in Scala? You could just s.filter(_ >= ' ') to throw away all control characters. If

Choosing a Scala web framework [closed]

ぐ巨炮叔叔 提交于 2019-12-03 01:10:22
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am about to start a project for a web application that should run on a Tomcat server. I have decided to go for Scala - the other

xsbt plugin 1.0.0-M7 and scalatra

☆樱花仙子☆ 提交于 2019-12-02 15:05:23
问题 I have tried upgrading the xsbt plugin to 1.0.0-M7 in my scalatra project but scalatra does not seem to be compatible with this version. When I try to reload my project I get the error below. I have tried with version 2.3.0 of scalatra Regards Des java.lang.NoClassDefFoundError: com/earldouglas/xsbtwebplugin/PluginKeys$ at org.scalatra.sbt.ScalatraPlugin$.<init>(ScalatraPlugin.scala:15) at org.scalatra.sbt.ScalatraPlugin$.<clinit>(ScalatraPlugin.scala) at java.lang.Class.forName0(Native

Choosing a Scala web framework [closed]

十年热恋 提交于 2019-12-02 14:29:07
I am about to start a project for a web application that should run on a Tomcat server. I have decided to go for Scala - the other alternative where I work being Groovy - essentially for type safety. I am now faced with the task of choosing the right tools for the job. The project I will need to develop will be accessed only through a JSON API. It will interact both with its own database and with two external services, which expose respectively a JSON and XML API. I will also need to be able to schedule periodic jobs where my application will execute various synchronization tasks with these

xsbt plugin 1.0.0-M7 and scalatra

旧巷老猫 提交于 2019-12-02 09:56:36
I have tried upgrading the xsbt plugin to 1.0.0-M7 in my scalatra project but scalatra does not seem to be compatible with this version. When I try to reload my project I get the error below. I have tried with version 2.3.0 of scalatra Regards Des java.lang.NoClassDefFoundError: com/earldouglas/xsbtwebplugin/PluginKeys$ at org.scalatra.sbt.ScalatraPlugin$.<init>(ScalatraPlugin.scala:15) at org.scalatra.sbt.ScalatraPlugin$.<clinit>(ScalatraPlugin.scala) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at sbt.ModuleUtilities$.getObject(ModuleUtilities.scala