Bahri Gökcan
Bahri Gökcan

Reputation: 1010

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?

Upvotes: 14

Views: 23162

Answers (5)

user2204107
user2204107

Reputation: 190

this works for me and maybe easier

  1. file menue => settings => Build, Execution, Deployment => sbt => check "Enable debugging for sbt shell"

  2. idea sbt shell now will start with debug enable, log out the port as "Listening for transport dt_socket at address: 52701"

  3. Run/Debug Configurations => Add(the pluss(+) sign) => Remote => Set "Port" And "Use module classpath"

  4. just type run in sbt shell, then click debug button

screent shot

  1. enable idea emaded sbt debug enter image description here
  2. sbt shell start log enter image description here
  3. add remote in "Run/Debug" enter image description here
  4. type run here enter image description here

Upvotes: 4

koppor
koppor

Reputation: 20501

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)

Upvotes: 5

M-sAnNan
M-sAnNan

Reputation: 804

  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

Upvotes: 4

ARM
ARM

Reputation: 351

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

Upvotes: 30

biesior
biesior

Reputation: 55798

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.

Upvotes: 11

Related Questions