Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug play2 in idea?

I found some articles on the internet and some discussions on google group, but they don't work any more.

How to do it with the latest play2-RC3 ?

like image 986
Freewind Avatar asked Feb 22 '12 07:02

Freewind


People also ask

How do I show debug in IntelliJ?

By default, the Debug tool window opens when your program hits a breakpoint and is not hidden when the session is terminated. To change this behavior, clear the Show debug window on breakpoint checkbox on the Build, Execution, Deployment | Debugger page of the IDE settings Ctrl+Alt+S .

How do I run a debug in play framework?

Generate configuration To debug, start your application with activator -jvm-debug 9999 run and in Eclipse right-click on the project and select Debug As, Debug Configurations. In the Debug Configurations dialog, right-click on Remote Java Application and select New. Change Port to 9999 and click Apply.

How do I debug a particular line in IntelliJ?

From the main menu, select Run | Debugging Actions | Smart Step Into or press Shift+F7 . Click the method. You can also select it using the arrow keys or tabs and press Enter / F7 .


2 Answers

You can start the play server in debug mode from console [docs], and should be able attach a debugger instance from Idea given that you know the port debugger is listening on.

I haven't use Idea so not sure if it is doable or not. It is fairly easy from netbeans. I suspect, it should be similar from Idea.

EDIT: They have also posted this in their customization guide for IDEs.

like image 94
Nasir Avatar answered Sep 28 '22 07:09

Nasir


Debugging Play 2.x is very easy with IntelliJ IDEA 12.x, here are the steps you have to do:

Step 1. Enable the Play Framework Support plugin and the Play 2.0 Support plugin in File > Settings > Plugins.

repo image

The generic plugin usually comes with IntelliJ but make sure it's enabled. The Play 2.0 Support plugin can be downloaded by clicking Install Jetbrains plugin.... Simply locate and install the plugin from the list, the latest working version for 12.x is v.0.2.49. (it may prompt that a Scala plugin needs to be installed aswell)

Step 2. Create a new Play app if you haven't or use an existing one

Step 3. Create a new Debug configuration: Run > Edit configurations...

You can click the + icon in the top left corner to add a new configuration. Simply select Play 2 app from the list and give the configuration a name. The default options should be correct but feel free to change them if necessary. When done, click Apply and Ok.

Step 4. Your toolbar should now have a Run icon and a Debug icon enabled.

play run/debug icon

Simply click the green arrow to run the Play application. This is the equivalent of doing play run from the commandline (except without the commandline).
To debug, click the green bug, next the the arrow. This is the equivalent of doing play debug from the commandline.

You will now be able to debug when a breakpoint is encountered.

Notes:

  • Make sure there is only 1 configuration running at a time because Play doesn't like multiple instances running at the same time.
  • If you're having trouble compiling, do a play clean-all and play package on the commandline, this should resolve most problems. If there are further problems, also try play idea from the commandline.
  • Make sure the Play configuration is filled in in your settings. You can do this by going to File > Settings > Play Configuration.

A video of these steps can also be found in this video by James Ward (start at around 1:40 min.).

like image 27
Aerus Avatar answered Sep 28 '22 06:09

Aerus