28
votes

Here we have a link

http://www.playframework.org/documentation/1.0.1/ide

about how to configure playframework to be working with different IDEs. There they say a couple of words about debugging, but it is not clear - how can I perform the debugging? If I put a break-point, let's say in my Model's constructor class, then how and what I should launch to initialize debugging? I use IntelliJ Idea.

For example when I use Jboss, or Tomcat, there is an option in the IDE within those servers to run them in debug mode or "normal" mode. But how to work with Play Framework in this context? Should I configure remote debugging somehow?

10
For those using Play 2, this tutorial was very helpful: digitalsanctum.com/2012/05/26/…wsanville
Follow up for play 2 at stackoverflow.com/q/24218341/873282koppor

10 Answers

41
votes

Most convenient way to run/debug applications in intellij IDEA is the following.

Menu command: Run -> Edit Configuration!

Edit configuration

Add new configuration -> Application

Then fill up the fields:

Main class:

play.server.Server

VM Parameters:

-Dapplication.path=.

You should have something similar:

configuration screen

If you did it correctly, then you can run and stop your app right from IDE

EDIT for Play! 2

Play 2 has good documentation for debugging. So go read it. But if you want to investigate run/debug buttons method - read further.

It is different for Play 2.

Settings:

Main class:

play.core.server.NettyServer or play.core.server.ProdServerStart

VM Parameters:

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999 -Dapplication.path=.

You still can debug your application by pressing debug button but I have not figured out some issues:

  • It always starts in PROD mode, so you can't make hot code changes.

  • RUNNING_PID. There is an error when you restart your debugging session saying that you have to delete this file.

18
votes

If its a play project, from the command line :

play debug

If its a SBT play project from the command line :

 sbt -jvm-debug 9999 run

debug port is 9999 by default

now create a remote configuration

in IntelliJ :

Go to "edit run configurations"

enter image description here

Create a new remote configuration (port 9999, all other details leave with default values)

enter image description here

run the new debug configuration (don't forget to put a break point)

17
votes

In Play 2, simply do the following:

  • From the shell, run play debug
  • You'll be dropped into the debug console. Type run and hit enter.
  • Then create a Remote configuration in IntelliJ IDEA set up for "localhost" and 9999.
  • Start the new configuration
10
votes

when you launch Play Framework (via play run) you will see that is says that the debug port is running at a certain address. This is a standard Java behavior on servers (having a debug port enabled).

Most IDEs allow you to set up a connection to that remote port so you can debug the code remotely. The specific steps will depend on the IDE you are using, but it should be as simple as that.

9
votes

I had to change this line in my build.sbt from:

fork in run := true

to

fork in run := false

for the breakpoints to work in IntelliJ IDEA 15.0 with the Play 2 App run configuration.

7
votes

I had a similar problem.

play (cloned from github at 2011-08-28) and intellij 10.5

SEVERE: Cannot read application.conf

my fix was: -Dapplication.path=. (without "")

to set -Djavaagent=... was no longer necessary on my box.

5
votes

Since version 11 of IDEA, there is native support for the Play framework in the ultimate edition. To debug your Play application do the following:

  • from the command-line, create a new demo app using 'play new demoapp'
  • from the command-line, create Intellij project/module files using 'play idea demoapp'
  • optionally edit .iml file and change '1.6' by '1.7' if you use the latest JDK (bug!)
  • start Intellij, and open the demoapp project
  • Go to Run/Edit Configuration
  • Press the '+' button, and add a 'remote' configuration
  • Choose Transport:socket, Debugger mode:Attach, Host:localhost, Port 8000
  • Set the 'name' and the 'classpath-module'
  • Start the Play! framework support in IDEA by choosing Tools/Play framework
  • Start the demo application by typing 'play run play101' in the Play! console
  • Set a breakpoint in the Application.java file on the 'render()' line
  • Start the 'remote' debug configuration.
  • In a browser, go to http://localhost:9000

You should now hit the breakpoint.

2
votes

With an SBT project, you can debug from the IDE debugger with an SBT Task configuration (Run->Edit Configurations-> Add New Configuration->SBT Task) - with the Tasks setting set to:

"run 9000" "-jvm-debug 9999"

9000 is the site port, 9999 is the default debug port. The quotes are required

Then select the configuration & debug

Works with the community edition (2016.2)

0
votes

my fix was: open the "Run/Debug Configurations" dialog, then change the "working directory" to the project directory.

0
votes

I just executed the application, on dev mode, on port 8080. Play automatically opens port 8000 for JVM debug.

Then create a new Run/Debug configuration with the template "Remote JVM Debug" and set the port to 8080.