Remote Debugging Play Framework

At times it is required to debug the code, debugging can be easy with any IDE. Running a play framework app and remote debug the application is possible by attaching the process and placing appropriate break points which would hit the breakpoint when the process is attached.

Start sbt-shell

Run Command clean compile test

This would result in starting a process with PID which can be traced from the sbt-shell window

opt/jdk1.8.0_181/bin/java -agentlib:jdwp=transport=dt_socket,address=localhost:35226,suspend=n,server=y -Xdebug -server -Xmx1536M -Didea.managed=true -Dfile.encoding=UTF-8 -Didea.runid=2018.2 -jar /home/sufia/.IdeaIC2018.2/config/plugins/Scala/launcher/sbt-launch.jar idea-shell
Listening for transport dt_socket at address: 35226

[sufia@sufia informis-server]$ lsof -i:35226
java 5981 sufia 4u IPv4 668592 0t0 TCP localhost:35226 (LISTEN)

In InteliJ->Run->Attach to Process, select the PID: 5981

This would hit the breakpoint and you would be able to debug through

The 92% chunk asset optimisation problem nodejs Angular5

At times running Angular Application on an environment which is fresh can be daunting. We may end up with errors which are not in alignment towards the development. One such of a case is the 92% chunk asset optimization problem when running a build of the Angular application.

On AWS hooked up an ec2-instance with Ubuntu 16.04, every thing works fine until you run the command npm run build.

We are stuck in an exception, 92% chunk asset optimisation and the dist directory is not created. Though we end up looking information on the development stack, but at times it could also be related to the Operating System SWAP space.

If the SWAP space on the OS if short or not available, this error shows up and to go around the error follow the instructions to check and allocate swap space on ubuntu. Hopefully this should help in getting around the problem.

One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. Swap is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM.

Basically, this gives you the ability to increase the amount of information that your server can keep in its working “memory”, with some caveats. The space on the hard drive will be used mainly when space in RAM is no longer sufficient for data.

The information written to disk will be slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fall back for when your system’s RAM is depleted is a good safety net.

sudo swapon -s

Another command for the same thing

free -m

Before we do this, we should be aware of our current disk usage. We can get this information by typing:

df -h

Although there are many opinions about the appropriate size of a swap space, it really depends on your personal preferences and your application requirements. Generally, an amount equal to or double the amount of RAM on your system is a good starting point.

Since my system has 4 Gigabytes of RAM, and doubling that would take a significant chunk of my disk space that I’m not willing to part with, I will create a swap space of 4 Gigabytes to match my system’s RAM.

Creating SWAP File
sudo fallocate -l 4G /swapfile
Check by running the following command that the SWAP file was created and space was reserved
ls -lh /swapfile
Enable SWAP Fiile
sudo mkswap /swapfile
Verfiy Permissions are set correctly
ls -lh /swapfile
Now that our file is more secure, we can tell our system to set up the swap space by typing:
sudo swapon /swapfile

We can verify that the procedure was successful by checking whether our system reports swap space now:

sudo swapon -s
Filename                Type        Size    Used    Priority
/swapfile               file        4194300 0       -1

We have a new swap file here. We can use the free utility again to corroborate our findings:

free -m

Samples on Play

Chat Application

Reactive, real-time log search with Play, Akka, AngularJS and Elasticsearch

Forums built with Play

Improving Play! 2.1 with Knockout.js


Optimizing Static Asset Loading with Play Framework



Neat Explanation of using JPA with Play:-

application.conf example :-–Framework-Example–Library/master/conf/application.conf



Action composition in the Play Framework


Building a REST API in Java and Scala Using Play Framework – Part 1


Dependency injection in Play Framework using Scala


Introducing the Google Guava Cache




Hibernate with JPA Annotations and Guice


Best of Breed Opensource on Play

File Cutters, File Spiltting playframework samples

grpc play framework:

Setting up PHP Environment for Development


NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index

URL url = Thread.currentThread().getContextClassLoader()

I’ve ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> “org.hibernate.javax.persistence” % “hibernate-jpa-2.0-api” % “1.0.1.Final”).

When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically you ended up having both jars in the classpath as transitive dependencies.

Edit your build.sbt file like this and it will temporarily fix you problem until play releases a new version of the jpa plugin for the newer api dependency.

libraryDependencies ++= Seq(
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.0.Final"

DB first – generating POJO on Ubuntu in Eclipse

At times eclipse in Ubuntu does not show up with menu items, to display the menu’s

sudo -H gedit /usr/share/applications/eclipse.desktop

Exec=ECLIPSE with Exec=env UBUNTU_MENUPROXY= eclipse

Ubuntu not showing eclipse menu

  1. Open your eclipse.desktop file:
    sudo -H gedit /usr/share/applications/eclipse.desktop

    (If you can’t find it in this path, try in ~/.local/share/applications/eclipse.desktop. Otherwise, you could have to find yours using locate command).

  2. Replace the Exec= line with this:
    Exec=env UBUNTU_MENUPROXY= eclipse

    Where “eclipse” is the path to your eclipse executable. In this case it’s just “eclipse” since there’s a symlink in /usr/bin folder.

    NOTE: If you can’t find your eclipse.desktop file, you can simply create one from scratch in the above path, and fill it with these lines:

    [Desktop Entry] 
    Exec=env UBUNTU_MENUPROXY= eclipse 
  3. Save the file.

Setting up Play Development Environment on Ubuntu

# Configure apt for java
apt-get update
apt-get install -y python-software-properties
add-apt-repository -y ppa:webupd8team/java
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections

# Update apt sources
apt-get update

apt-get install -y unzip wget git vim oracle-java8-installer oracle-java8-set-default

# Install scala
cd /opt
tar -zxvf scala-2.12.0.tgz
# end scala

#Installing playframework on ubuntu there are two options

Go to, download the offline installer close to 617MB


# Install play with activator
#Download and Install Play (the folder should have permission to write)
#mv activator-1.3.12-minimal activator

The off-line installer downloads all the dependencies required to run play applications. In a scenario where in we download only the small foot print of activator the dependencies are downloaded at the time of loading the project, which can be annoying and time consuming.

Follow the instructions at to install the play and chose “installing play with activator” and follow instructions listed
Extracting Activator

Extract the archive on a location where you have write access. Running activator writes some files to directories within the distribution, so don’t install to /opt, /usr/local or anywhere else you’d need special permission to write to.
Adding Activator to your Path

For convenience, you should add the Activator installation directory to your system PATH:

export PATH=$PATH:/opt/activator/bin

source ~/.bashrc

Making the activator as an executable execute the following command

sudo chmod a+x /activator/bin/activator

Just in case after executing the above commands and when we issue activator in the terminal, if it says command not found, we need to manually edit the bashrc file as follows

gedit source ~/.bashrc

add the command to the bottom of the file

export PATH=$PATH:/opt/activator/bin


mv typesafe-activator-1.3.12 activator

cd /opt
export PATH=$PATH:/opt/activator/bin
source ~/.bashrc
sudo chmod a+x /activator/bin/activator
# end play with activator

#echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin:/opt/play-2.2.5’ >> /etc/profile
echo ‘PATH=${PATH}:/opt/scala-2.12.0/bin’ >> /etc/profile

echo ‘PATH=${PATH}:/opt/activator/bin’ >> /etc/profile

sudo apt-get install git

echo “Installing IntelliJ IDEA…”

# We need root to install
[ $(id -u) != “0” ] && exec sudo “$0” “$@”

# Attempt to install a JDK
# apt-get install openjdk-8-jdk
# add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer

# Prompt for edition
#while true; do
#    read -p “Enter ‘U’ for Ultimate or ‘C’ for Community: ” ed
#    case $ed in
#        [Uu]* ) ed=U; break;;
#        [Cc]* ) ed=C; break;;
#    esac

# Fetch the most recent version
VERSION=$(wget “” -qO- | grep -P -o -m 1 “(?<=[^/]+(?=/)”)

# Prepend base URL for download

echo $URL

# Truncate filename
FILE=$(basename ${URL})

# Set download directory

echo “Downloading idea-I$ed-$VERSION to $DEST…”

# Download binary
wget -cO ${DEST} ${URL} –read-timeout=5 –tries=0

echo “Download complete!”

# Set directory name

echo “Installing to $DIR”

# Untar file
if mkdir ${DIR}; then
tar -xzf ${DEST} -C ${DIR} –strip-components=1

# Grab executable folder

# Add permissions to install directory
chmod -R +rwx ${DIR}

# Set desktop shortcut path

# Add desktop shortcut
echo “[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application” -e > ${DESK}

# Create symlink entry
ln -s ${BIN}/ /usr/local/bin/idea

echo “Done….Installing IntelliJ IDEA…”

echo “Start….Installing Scala..”