Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Play Framework 2.x in debug mode in IntelliJ IDEA?

I want to run Play Framework 2.x in debug mode in IntelliJ IDEA. I searched in the Internet and all results say that you have to use play console.

Is it possible to run in debug mode in IntelliJ IDEA without using play console?

like image 840
Bahri Gökcan Avatar asked Jun 14 '14 09:06

Bahri Gökcan


People also ask

How do I run a debug in play framework?

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 run a program in debug mode IntelliJ?

Run the program in debug mode Click the Run icon in the gutter, then select Modify Run Configuration. Enter arguments in the Program arguments field. Click the Run button near the main method. From the menu, select Debug.

How do I run a framework project in IntelliJ?

Open an existing Play 2 project In the dialog that opens, locate your project and if it is an sbt project, select the build. sbt file and click Open. In the dialog that opens, click Open as Project. IntelliJ IDEA opens the project and loads all the necessary dependencies.

How do I run a play framework?

To run a Play application: Create a new Run Configuration – From the main menu, select Run -> Edit Configurations. Click on the + to add a new configuration. From the list of configurations, choose “sbt Task”


4 Answers

Using activator :

  1. From Terminal (Not intellij terminal), enter command : activator ui
  2. Open your existing app
  3. Choose "Code view & Open in IDE
  4. In Browse Code, click setting icon
  5. Choose Open Project in Intellij IDEA
  6. Generate

  7. Open Intellij IDEA

  8. Open project - browse your app directory
  9. Run - Edit Configuration
  10. Add new configuration - Remote
  11. Add name Setting transport : socket, debugger mode : attach, Host : localhost, port : 9999 module clashpath : your app
  12. Tools - Open Terminal
  13. activator -jvm-debug 9999 run
  14. Run debug
  15. Open browser localhost:9000
like image 119
ARM Avatar answered Oct 18 '22 00:10

ARM


You need to use Idea 12+ Ultimate Edition

  • Install Play 2.0 Support, Scala and other required plugins in Idea
  • In command line perform play idea to generate project
  • Open created project in Idea (open, don't import)
  • Go to: Menu > Run > Edit Configurations... > Add New Configuration... > choose Play 2 App
  • In Menu > Run new buttons will appear Debug and Run, first will run app with enabled debbuger.
like image 29
biesior Avatar answered Oct 18 '22 00:10

biesior


Preparation: Do not use the project creation by activator ui or similar. Just open the project in IntelliJ.

  1. activator -jvm-debug 9999 ~run. The ~ before run enables automatic reloading of generated HTML pages
  2. In IntelliJ:
    1. Run > Edit Configurations...
    2. Select Defaults/Remote
    3. Click on the green + at the upper left corner
    4. Give the name "Play 2"
    5. Ensure that Transport:Socket and Debugger mode:Attach are selected
    6. Type in 9999 as port Preferences Screenshot
    7. Press "OK"
  3. Run > Debug Play 2 (second entry in the list)

Pro hint: Check out the play-auto-refresh plugin to have Chrome automatically reloading on a change.

(based on @ARM's answer)

like image 5
koppor Avatar answered Oct 18 '22 00:10

koppor


  1. Open Intellij IDEA
  2. Open project - browse your app directory Run - Edit Configuration
  3. Add new configuration - Play2
  4. Add http://localhost:9000 to url to open option
  5. Add -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M to JVM option
  6. Set Debug port to 9999
  7. Set your debug point and debug your application. Cheers :)

FYI : All of the above fields might filled up already

enter image description here

like image 3
M-sAnNan Avatar answered Oct 17 '22 22:10

M-sAnNan