Deploying Play Framework 2.3.x (Java style) on Ubuntu 14.04 production server - deployment

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.

Related

Sbt not loading the project from its current directory

When I run SBT in my Scala project that contains a build.sbt file, SBT seems to ignore it and loads the project definition from a different folder and set the current project to that different directory hsperfdata which is weird because this is used as part of Java's performance counter which has nothing to do with what I'm trying to do.
Also SBT was installed via SDKMAN and when I try to specify a lower SDK version 1.2.8 instead of 1.4.6 it will always use 1.4.6. version 1.2.8 is also specified in my build.properties file as well.
My stack trace:
xxxxx#MC-N369748 topic-api % sbt
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] welcome to sbt 1.4.6 (AdoptOpenJDK Java 1.8.0_275)
[info] loading project definition from /private/var/folders/hs/0vkhntfd557c8z8g8b_p7ly00000gp/T/hsperfdata_adu-tp01/project
[info] set current project to hsperfdata_adu-tp01 (in build file:/private/var/folders/hs/0vkhntfd557c8z8g8b_p7ly00000gp/T/hsperfdata_adu-tp01/)
[info] sbt server started at local:///Users/xxxxx/.sbt/1.0/server/143baa47709c908603e6/sock
[info] started sbt server
sbt:hsperfdata_xxxxx>
When we had this issue, it was caused by OS X restricting the permissions of the java executables. Since the process is not able to read/write to the current directory, sbt diverts to the tmp folder.
In System Preferences => Security & Privacy make sure the Full Disk Access property is turned on for the appropriate executables (probably java and javac in this case) or move your source code our of what OS X considers the protected part of the file system (we moved our builds from the user home directory to /code and sbt worked fine).

Does lombok work with GWT super dev mode?

I use lombok extensively at backend, it's really nice and I hope to integrate it into GWT, so I can take advantage of the magic.
I managed to let gwt-maven-plugin recognize lombok by using the -javaagent:lombok.jar=ECJ vm args to be able to compile successfully, however, I'm not sure how to make it work with GWT super dev mode, as it continues complaining "missing getter method" in my IDE(Intellij IDEA).
Also tried the delombok goal of lombok-maven-plugin but without luck.
Any ideas?
Make sure to delete your workDir before starting gwt:run-codeserver. This directory might contain files from previous (lombok-unaware) compilation attempts.
[INFO] --- gwt-maven-plugin:2.8.0-beta1:run-codeserver (default-cli) # Web ---
[INFO] Turning off precompile in incremental mode.
[INFO] Super Dev Mode starting up
[INFO] workDir: C:\Users\jzaruba\AppData\Local\Temp\gwt-codeserver-1653004051676437159.tmp
This is what my mvn-gwt-codeserver.bat looks like:
call mvn clean dependency:properties gwt:run-codeserver %*
(I added dependency:properties because my gwt-maven-plugin configuration refers to Lombok via project dependency: ${org.projectlombok:lombok:jar}, i.e. no static path.)
And if you don't like launching the codeserver from command line, this is how "VM arguments" in my "GWT Codeserver" launch configuration look like:
-javaagent:path/to/lombok.jar=ECJ

How fix sigar library when I run spray application?

I have a sbt project written in scala. The project uses akka and spray. There is a class with main function. When I run scala console application sometimes I get
[on-spray-can-akka.actor.default-dispatcher-4] [DEBUG] [2014-11-07 16:48:30,336] Sigar: no sigar-amd64-winnt.dll in java.library.path
org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path
I do not change anything run it again and it runs well. So it can be run successful or fail several times on end. How to fix this?
UPDATED
Also when it start normal there is a message:
[INFO] [11/07/2014 17:02:36.772] [on-spray-can-akka.actor.default-dispatcher-2]
[Cluster(akka://myApp)] Cluster Node [akka.tcp://myApp#127.0.0.1:2551] - Metrics will be
retreived from MBeans, and may be incorrect on some platforms. To increase metric accuracy
add the 'sigar.jar' to the classpath and the appropriate platform-specific native libary to
'java.library.path'. Reason: java.lang.IllegalArgumentException: java.lang.UnsatisfiedLinkError:
org.hyperic.sigar.Sigar.getPid()J
Sigar is a native library for gathering performance stats, used by Typesafe Console atmos Scala library. If you're not interested in hooking up Typesafe Console to your application, you can simply remove all references to atmos library from sbt build script and app config files without affecting your app functionality.

GWT Maven : Module 'xxx' may need to be (re)compiled

Problem: Keep getting "module 'xxx' may need to be (re)compiled".
Steps:
Importing a sample GWT-Maven project into eclipse ("MobileWebApp" - from the GWT SDK).
GWT|compile the project.
Running in production mode (without the codesvr parameter, i.e. using "localhost:8888/MobileWebApp.html").
Notes:
I am fairly new to both GWT and Maven.
I read GWT module may need to be (re)compiled REDUX.
Dev mode does work (I am able to debug the application).
Detailed Steps:
Copying the "MobileWebApp" folder from the "samples" folder inside the GWT SDK (version 2.5.1) to my eclipse workspace.
Importing the project: File->Import->Existing Maven Projects (pointing to the "MobileWebApp" folder where the pom.xml exists.
Configuring the project following these steps: https://developers.google.com/eclipse/docs/faq?hl=iw#gwt_with_maven
At this point I am able to run the app as "Web Application" and debug it.
Running GWT|Compile: The nocache.js stuff is being placed in the target folder.
Now, when i try to run the app in production mode I am getting the (re)compile error.
Logs:
"DataNucleus Enhancer (version 1.1.4) : Enhancement of classes
DataNucleus Enhancer completed with success for 0 classes. Timings : input=713 ms, enhance=0 ms,
total=713 ms. Consult the log for full details
DataNucleus Enhancer completed and no classes were enhanced. Consult the log for full details"
"Compiling module com.google.gwt.sample.mobilewebapp.MobileWebApp
Validating units:
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Compiling 6 permutations
Compiling permutation 0...
Compiling permutation 1...
Compiling permutation 2...
Compiling permutation 3...
Compiling permutation 4...
Compiling permutation 5...
Compile of permutations succeeded
Linking into D:\workspace\eclipse\MobileWebApp\target\MobileWebApp-1.0-SNAPSHOT\mobilewebapp
Invoking Linker AppCacheLinker
Be sure your landing page's tag declares a manifest:
Link succeeded
Compilation succeeded -- 152.077s"
"Initializing App Engine server
06/07/2013 20:12:33 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
06/07/2013 20:12:33 com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed D:\workspace\eclipse\MobileWebApp\target\MobileWebApp-1.0-SNAPSHOT\WEB-INF/appengine-web.xml
06/07/2013 20:12:33 com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed D:\workspace\eclipse\MobileWebApp\target\MobileWebApp-1.0-SNAPSHOT\WEB-INF/web.xml
06/07/2013 20:12:34 com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
06/07/2013 20:12:36 com.google.apphosting.utils.jetty.JettyLogger info
INFO: Started SelectChannelConnector#0.0.0.0:8888
06/07/2013 20:12:36 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at localhost:8888/
06/07/2013 20:12:36 com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at localhost:8888/_ah/admin
Linking modules
Bootstrap link for command-line module 'com.google.gwt.sample.mobilewebapp.MobileWebApp'
Linking module 'mobilewebapp'
Invoking Linker AppCacheLinker
DevMode warning: Clobbering appcache.nocache.manifest to allow debugging. Recompile before deploying your app!
Be sure your landing page's tag declares a manifest:
06/07/2013 20:13:38 com.google.apphosting.utils.jetty.AppEngineAuthentication$AppEngineAuthenticator authenticate
INFO: Got /MobileWebApp.html but no one was logged in, redirecting."
Pom.xml: https://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/mobilewebapp/
Thanks ahead.
Answering my own question:
1) from command: "mvn gwt:run".
2) Google|GWT compile.
P.S. As much as I am happy figuring that out (after agonizing couple of days) I would still like to know the reasons of why I have to - first lunch the app then compile it. Very strange - in my humble opinion.
offtopic: This sample app was supposed to be "offline executable" (from mobile, at the very least) - so how exactly do I test it? I tried (after running the app once or twice from mobile device, so that it will be cached) to switch to airplane mode and navigating to the app (just like he demonstrated) but, obviously(?), the server is not reachable.. Do I need to enable something specific for it to work? (my mobile device is Google-Nexus-4)
Multiple steps:
Update Project properties -> deployment Assembly using Deploy GWT maven project with eclipse deploys webapp directory instead of target/project directory
mvn clean package
mvn gwt:compile
In eclipse, click on 'GWT Compile Project' -> Advacned -> Remove '-war src/main/webapp' argument and hit compile.
Output should be like this -
Linking into target/project-1.0-SNAPSHOT/ModuleName
Now the deployment should work fine.

Play2 run via Sbt in dev mode on Osx Causes Out of Memory

I can't seem to find similar issues.
On OSX, play2 bin seems to run okay but using sbt causes oom errors and scala files never complete compiling
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on port 9000...
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 15 Scala sources and 2 Java sources to
/Users/tripled153/Development/src/Foundation/playApp/target/scala-2.9.1/classes...
Java HotSpot(TM) 64-Bit Server VM warning: Exception
java.lang.OutOfMemoryError occurred dispatching signal Unknown Signal
to handler- the VM may need to be forcibly terminated
I'm running with extended memory settings but still no luck. Running in staged (prod) mode appears okay though.
rundev.sh
export SBT_OPTS="-Xms512M -Xmx3536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=512M"
sudo sbt clean run