I am starting the the application from the command line using either
activator run
activator ~run
or after I start the activator console I use run or ~run.
everything seems to work and it gives the expected
--- (Running the application, auto-reloading is enabled) ---
play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
I can view the application in the browser and I can make changes in the code and they are reloaded just fine. the issue is that after only a couple minutes it seems like something "times-out" because if I try to reload after this the browser just sits there spinning.
if i let it spin long enough I get.
[error] application -
[info]
[info] ! Internal server error, for (GET) [/] ->
[info]
[info] java.util.concurrent.TimeoutException: Futures timed out after [300000 milliseconds]
[info] at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) ~[scala-library-2.11.1.jar:na]
[info] at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223) ~[scala-library-2.11.1.jar:na]
[info] at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:111) ~[scala-library-2.11.1.jar:na]
[info] at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) ~[scala-library-2.11.1.jar:na]
[info] at scala.concurrent.Await$.result(package.scala:111) ~[scala-library-2.11.1.jar:na]
I would really appreciate any help. Since having to restart the app all over again each time I make a change really takes away the appeal of the framework.
I upgraded to activator 1.3.2 with Play 2.3.9 and I also had the same issue. It drove me nuts. I found that the cause was the new set "fork in run" setting added in activator 1.3.2.
Open up build.sbt and you will find :
fork in run := true
Set this to false as follows :
fork in run := false
Running activator start or better sbt start fixes the issue as well without having to remove the forking behavior.
Related
When running scala in sbt via runMain I have the issue that some output written via println is cut off. If I run the following code by running sbt "runMain aw.OutputTry" the output start to get cut off around at some point.
package aw
object OutputTry {
def main(args: Array[String]) {
for(i <- 1 to 5000) {
println(f"${i}")
}
}
}
Example output (I snipped the output at the '...'):
uhu01#DESKTOP-4LSJM58:~/git/spinal$ sbt "runMain aw.OutputTry"
[info] Loading settings for project spinal-build from metals.sbt,plugins.sbt ...
[info] Loading project definition from /home/uhu01/git/spinal/project
[info] Loading settings for project spinal from build.sbt ...
[info] Set current project to aw (in build file:/home/uhu01/git/spinal/)
[info] sbt server started at local:///home/uhu01/.sbt/1.0/server/771a115d7899feb4b3f3/sock
sbt:aw> runMain aw.OutputTry
[warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list
[info] Running (fork) aw.OutputTry
[info] 1
[info] 2
[info] 3
...
[info] 963
[info] 964
[info] 965
[success] Total time: 4 s, completed Apr 13, 2020 11:15:55 PM
I assume some buffering is going on in sbt to e.g. prepend the output with the [info] tag? To me the behavior looks a bit like a buffer in sbt is not flushed after the program exists.
Things I tried:
Flushing the output in the scala code (by calling Console.flush() in the loop, after println) - does not help
In the sbt documentation I could find the setting logBuffered, I checked this and it's already set to false
Pipe the output of the sbt call to a file - then all lines are visible as expected
Calling Thread.sleep(1000) before exiting only moves the problem, and would not be a solution in any case
I first suspected my environment (shell, etc.) but running the code directly in a scala REPL works as expected
Is there some sbt setting that I did overlook during my search? Any tips how to get shown the full output?
Environment: I'm using sbt 1.2.7, Scala 2.11.12 and openjdk 1.8.0_424 on Ubuntu 18.04 in WSL
sbt 1.2.7 is a pretty old version. Try 1.3.9 (latest as of April 2020).
(And remember that in order to keep builds reproducible, your sbt version is determined by your project/build.properties file, not by what you have installed.)
I am trying to learn Scala by implementing a simple API in Play framework. I am creating an app by command
activator new app play-scala
Then in app folder I'm doing activator run then it starts downloading tons of data from internet. I tried offline:=true in build.sbt and using the offline version activator instead of minimal one but with no success.
[info] Loading project definition from /home/amit/Codes/scala/app/project
[info] Updating {file:/home/amit/Codes/scala/app/project/}app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to app (in build file:/home/amit/Codes/scala/app/)
[info] Updating {file:/home/amit/Codes/scala/app/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-omnidoc_2.11/2.5.3/play-omnidoc_2.11-2.5.3.jar ...
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.sbtrc/client-2-11/0.3.1/jars/client-2-11.jar ...
[info] [SUCCESSFUL ] com.typesafe.sbtrc#client-2-11;0.3.1!client-2-11.jar (102499ms)
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.11.5/scala-reflect-2.11.5.jar ...
[info] [SUCCESSFUL ] org.scala-lang#scala-reflect;2.11.5!scala-reflect.jar (136599ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/serialization_2.11/0.1.0/jars/serialization_2.11.jar ...
[info] [SUCCESSFUL ] org.scala-sbt#serialization_2.11;0.1.0!serialization_2.11.jar (12655ms)
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/io_2.11/0.13.8-M3/jars/io_2.11.jar ...
I have a very slow connection and I am stuck with it. I don't know something that easy in python-flask can be so difficult in scala-play or am I missing something?
By issuing activator new app play-scala activator only creates a copy of template (usually located at ~/.activator//templates). Of course template itself has to be downloaded first but it is normally tiny.
Effect what you are seeing is that when you run activator run the SBT first time resolves dependencies of your application created according to template. Two situations can happen:
you have already a lot of dependencies in your ~/.ivy2 directory because e.g. you have created project according to the template before or project with similar dependencies via SBT (not strictly with activator). Then the dependencies will be resolved and not downloaded.
you have no dependencies at all in ~/.ivy2 or your template uses such different ones that they have to be downloaded.
Your milage may vary, but important point is that your dependencies are related to your template not activator itself. Another important thing to note is that they have to be definitely downloaded at least once to be used (this is strongly dependent from state of your ~/.ivy2 directory).
I guess that you are trying activator for the first time, or at least play-scala template, thus you have to wait and definitely use better internet connection :)
Hello I'm upgrading my gwt from 2.4.0 to 2.7.0 with gxt 2.3.1a. Everything was looking alright ultil I try to debug the application. I start the debug using superdev mode without any problems aparently. Here is the end of my debug start.
"
[INFO] Unification traversed 108163 fields and methods and 8186 types. 8146 are considered part of the current module and 8146 had all of their fields and methods traversed.
[INFO] Compiling 1 permutation
[INFO] Compiling permutation 0...
[INFO] Linking per-type JS with 8130 new types.
[INFO] prelink JS size = 26317582
[INFO] prelink sourcemap = 26317582 bytes and 534648 lines
[INFO] postlink JS size = 26027857
[INFO] postlink sourcemap = 26027857 bytes and 528723 lines
[INFO] Source Maps Enabled
[INFO] Compile of permutations succeeded
[INFO] Compilation succeeded -- 128,510s
[INFO] Linking into C:\Users\ALEXAN~1.RIS\AppData\Local\Temp\gwt-codeserver-3435183735990420589.tmp\br.com.webb.ria.Application\compile-2\war\br.com.webb.ria.Application; Writing extras to C:\Users\ALEXAN~1.RIS\AppData\Local\Temp\gwt-codeserver-3435183735990420589.tmp\br.com.webb.ria.Application\compile-2\extras\br.com.webb.ria.Application
[INFO] Link succeeded
[INFO] Linking succeeded -- 11,742s
[INFO] 147,211s total -- Compile completed
"
After I start the remote debug I get the normal gray window of gwt debug plugin. Everything is processed without any errors. When I copy the generated link on my browser I get the following message.
"Compiling br.com.webb.ria.Application" My gwt module.
The problem is that after the message vanishes I get nothing but the plain html. The module is not loaded on screen and I can't see my application.
I've tried using the "Dev Mode On" button from my bookmark, nothing happens. I tried to stop using "Dev Mode Off" and then clicking on "Dev Mode On" again, nothing happens.
I also tried enabling https support and <set-property name="user.agent" value="safari" />. Nothing seems to help. Any ideas?
Unlike convencional debug mode, superdev mode requires a full compilation before debuging to work. If you are using maven and face the same problem, perform a mvn clean package before trying to debug.
I have a Play application on my laptop, which I am trying to get running on my production server. Locally the application compiles and works without errors.
On my production server, I do the following:
root#example:~/mysite# ./activator
[info] Loading project definition from home/mysite/project
[info] Set current project to mysite (in build file:/home/mysite/)
[mysite] $ ~run
--- (Running the application, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 4 Scala sources and 2 Java sources to /home/mysite/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
Killed
root#example:~/mysite#
As you can see, `compiler-interface' is not yet compiled. I am wondering why this is. Is this because I don't have the Scala compiler installed?
Probably the Killed part is because you don't have enough memory to compile your application.
Either way I think it would be better to deploy your app already compiled than compile it on place. You can do that using ./activator dist.
This will generate a zip file in YOUR_PROJECT_DIR/target/universal named YOUR-PROJECT-NAME-VERSION.zip with everything already compiled and with every needed dependency packaged already. You can then upload this file to somewhere in your production server, extract it and then start the server using
$ EXTRACTED_FOLDER/bin/YOUR-APP-NAME
If you still want to build it in your production server, try to reduce the memory used by activator using
$ ./activator -mem 200 # MAX 200mb
// (...)
[PROJECT-NAME] ~start
Note that ~run will start your server in dev mode (ie sensible information like stacktraces etc can be shown on error) and recompile it on changes, so you may want to use start or ~start instead.
I am getting the following exception after starting activator ui from command line.
Checking for a newer version of Activator (current version 1.2.2)...
... our current version 1.2.2 looks like the latest.
Found previous process id: 2988
FOUND REPO = activator-local # file:////C:/shakti/scala/typesafe-activator-1.2.2
/activator-1.2.2/repository
Play server process ID is 5712
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /127.0.0.1:8888
[ERROR] [06/15/2014 05:46:13.851] [default-akka.actor.default-dispatcher-3] [ActorSystem(default)] Failed to download http://downloads.typesafe.com/typesafe-activator/index/v2/index-07064250cfd1cc2444f19c731541332ccf93bc13.zip: sbt.TranslatedIOException: Error opening http://downloads.typesafe.com/typesafe-activator/index/v2/index-07064250cfd1cc2444f19c731541332ccf93bc13.zip: java.net.UnknownHostException: downloads.typesafe.com
[INFO] [06/15/2014 05:46:13.860] [default-akka.actor.default-dispatcher-3] [akka://default/user/template-cache] Unable to check remote server for template updates.
[INFO] [06/15/2014 05:46:19.155] [default-akka.actor.default-dispatcher-2] [akka://default/user/home-socket-1] Firing up web socket
What could be the reason and how to fix it?
Seems it was an intermittent issue due to some network problem. It is working fine now.
I resolve this prolem using ./activator ui instead using activator ui on linux