scala-ideplayframework-2.6

not able to debug play framework 2.6.x application in Scala IDE


I am new to Play, I have installed SBT 1.0.2, Scala IDE 4.6.1, from play documentation downloaded play-scala-starter-example project, i want to debug the project, i did following things.

  1. set environment variables SBT_OPTS to -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999
  2. tried to run the project with "sbt -jvm-debug 9999 run" but it gives "Not a valid command: jvm-debug"
  3. ran it with "sbt run" and in Scala IDE, i created following configuration, and added breakpoints in HomeController of sample project, but when i refresh the page running on port 9000 doesnt stop, and when i use "Scala Debugger (Socket Attach) it gives error "Failed to connect to remote VM. Connection timed out." Scala IDE Configuration

Solution

  • 1) Add sbt eclipse plugin in you project.sbt

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.2")
    

    2) Set the environment as for debugging follow

    set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5555
    sbt run
    

    3) Attache debugger to remote application in eclipse as

    i) In Eclipse, right-click your project, then choose Debug As -> Debug Configurations...

    ii) Right-click Remote Java Application, then click New. The host should already be set to localhost. Set the port to 5555 (the default port used by the play debug run command).

    iii)Click Apply to save, then Debug to connect to your running Play instance