Play Framework 2 Tutorial: Debugging with IntelliJ IDEA
A tutorial on how to debug Play Framework applications using the IntelliJ IDEA IDE
In this post I’ll describe how to debug a Play Framework app using IntelliJ IDEA.
Here are the versions used for this post:
- IntelliJ IDEA 11.1.2
- Play Framework 2.0.1
Create IDEA Project Files
There’s a single step from the Play console which will create the IDEA project files and setup your app’s classpath with the libraries it depends on.
From the root directory of your Play app…
Note that if you change any of your projects dependencies, you’ll have to re-run the “idea” command.
IntelliJ IDEA New Project Setup
The following screenshot show the steps necessary to setup your new project and use the generated project files from the “idea” Play command above:
Start by creating a new project and unchecking the “Create module” checkbox:
Choose “Import existing module” and select the *.iml file generated with the “idea” command from the Play console:
You should see the “app” and “test” folders highlighted as seen below:
You should also see several dependencies added to your app:
IntelliJ IDEA Debugger Setup
Now that your Play Framework app is setup in IDEA let’s setup a Run/Debug configuration:
- Open Run/Debug Configurations dialog, then click Run -> Edit Configurations
- Add a Remote configuration, then select Remote
- Configure it:
- Set a name
- Transport: Socket
- Debugger mode: Attach
- Host: localhost
- Port: 9999
- Select module you imported
- Close dialog - click Apply
Debugging with IDEA
To debug your application:
From the command prompt, run
play debug and you should see something like the following:
- Set one or more breakpoints in your app
- Then open your browser to http://localhost:9000 and observe something like the following
Play Console in IntelliJ IDEA
Support for the Play Framework in IntelliJ IDEA is pretty basic as of this writing but you can run the Play console from IDEA via:
Tools > Play with Playframework...
Vote for Better Play Framework Support!
If you’d like to see better support for Play Framework 2.0 in IntelliJ IDEA, vote for it here: