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

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"

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..”

Installing SBT on Ubuntu

Sbt is the default build tool for Scala. This post talks about steps to install sbt on ubuntu.

Steps to Install SBT on Ubuntu

#Add typesafe repository     
wget `

#Install the repository
sudo dpkg -i repo-deb-build-0002.deb

sudo apt-get update

#Install sbt
sudo apt-get install sbt

#check whether sbt is installed


Add Specific Version of SBT

Some project need specific version of sbt like 0.13.

If you get error saying

Detected sbt version 0.12.2 Cannot find sbt launcher 0.12.2 Please download: From… To /home/{username}/.sbt/.lib/0.12.2/sbt-launch.jar

Run the following commands by replacing with your username.

mkdir -p /home/{username}/.sbt/.lib/0.12.2/ 
 wget -O /home/{username}/.sbt/.lib/0.12.2/sbt-launch.jar

Step by Step load existing Play Project in IDEA

While setting up play with IDEA, it could be daunting to get things right in the first go itself. A step by step tutorial to help one out in setting up a development environment and trouble shooting issues while setting it up.

It starts off with having per-requisites on your OS. If you are looking out for a complete development environment bash script to wire up an environment you could look up earlier post, Bash Script for Play Development Environment

Once you have the Development Environment, we then proceed to load existing data sources as an IDEA project. We need to ensure before we move in that appropriate plug-ins are installed.

Pre-Requisites for IDEA

  • Add SBT Plugin: File->Settings->Plugins->Browse repositories-> SBT-> Install
  • Add Scala: File->Settings->Plugins->Browse repositories-> Scala->Install


Checkout the project from the repository.

Navigate to the location where the sources would like to be cloned. On the bash issue the clone command to clone the repository.

git clone https://xxxxxx.xxxxxx.git

The command would clone the repository locally in the folder.

Load the Project

Open IDEA, Select option Import Project-> Open the Project Folder (datacaptive)-> open the folder by name Project (project) -> Select file build.sbt

Open the Project by pointing to build.sbt project file in the project folder.

In case the SDK is not selected following error is got, associate appropriate JDK by clicking “New” select JVM (located at /usr/lib/jvm/java-8-oracle)


IDEA would start to resolve dependencies. It might take a little long to resolve for the first time.


After IDEA resolves the dependencies, it inquires to select the modules/data to include in the project


On resolving the project would be loaded, as shown below


Exceptional scenarios while loading the project

Controller Errors

Some time, the project would not load as anticipated. Following are some scenarios which were encountered and how they had been tackled.

If you encounter errors on Controllers, open up the sbt console in IDEA

SBT Console in IDEA

run clean and compile commands and issue a build for the project.

Create a Run Configuration as shown at the bottom of this post.

Run Successfuly


sbtrc client

Just in case On Resolving Dependencies, if there are errors “like unable to find sbtrc…”


[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbtrc#client-2-11;0.3.1: not found
[warn] :: com.typesafe.sbtrc#actor-client-2-11;0.3.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::

projects-> play-fork-run.sbt -> comment out

addSbtPlugin("" % "sbt-fork-run-plugin" % "2.5.9")

If I remove “sbt-fork-run-plugin” from that project, then it resolves the sbtrc dependencies.

I’m not sure if this is an Activator or SBT bug.

Unable to resolve symbol IDEA

When loading a project in IDEA, cannot resolve symbol with play framework occurs or does not exist

Solved it by "File" > "Open Project" and choose the base folder of the Play framework project (delete all idea settings file from the folder before so that it will reimport using the SBT settings).

Source Folder not loaded

The above steps at times would not reflect the Project Source files. In such  a case,

  1. closed IntelliJ,
  2. deleted the .idea folder or stash it
  3. restarted IntelliJ and opened the same project.

IntelliJ will generate the new .idea folder and the folders will appear.

Run Configuration

  1. Create a new Run Configuration – From the main menu, select Run -> Edit Configurations
  2. Click on the + to add a new configuration
  3. From the list of configurations, choose “SBT Task”
  4. In the “tasks” input box, simply put “run”
  5. Apply changes and select OK.
  6. Now you can choose “Run” from the main Run menu and run your application

data captive run configuration