I know that for the classic Play framework it's play debug ~run
. I tried running activator debug ~run
but I get the following error:
[error] Not a valid command: debug (similar: idea)
[error] Not a valid project ID: debug
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: debug (similar: debianSign, node)
[error] debug
[error] ^
What am I doing wrong?
If you're just doing activator ~run
, then you should be able to pass a JVM debug port option with:
./activator -jvm-debug <port> ~run
This may not do the same thing as play-run, but here's the arguments it's adding to the command line:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<port>
From: https://github.com/typesafehub/activator/blob/master/dist/src/templates/activator#L107
I've successfully attached to this process in my IDE.
If you're running in windows, the automatic configuration is a bit different. With the latest activator, you can do the following:
%UserProfile%\.activator\activatorconfig.txt
(The UserProfile is different depending on your windows install. Mine is C:\Documents and Settings\jsuereth
on one installation and C:\Users\jsuereth
on another). Past the following in the file:
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<PUT YOUR PORT HERE>
set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=<port>"
Hope that helps!
I have windows7 and activator 1.2.12, and the answers above didn't work for me. Instead, I used the "-jvm-debug" option of the "activator.bat" command of the project home folder, and it worked. Like this:
C:\Projects\MyProject>activator -jvm-debug Listening for transport dt_socket at address: 9999 [info] Loading global plugins from C:\Users\MyAccount\.sbt\0.13\plugins [info] Loading project definition from C:\Projects\MyProject\project [info] Set current project to MyProject (in build file:/C:/Projects/MyProject/)
Then, inside the activator (sbt), I used the "run" command. Like this:
[MyProject] $ run --- (Running the application, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 'force' enabled (Server started, use Ctrl+D to stop and go back to the console...) Running "watch" task
To debug from 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". From now on you can click on "Debug" to connect to the running application.
Another thing that I discovered:
fork in run := false
fork in Test := false
in "build.sbt".
This enables you to debug your tests, not only the application itself.
With the Play framework 2.x:
Inside your project directory, run the activator command like
activator -jvm-debug 9999 run
Once this is done, debug your project as Remote Java Application within your IDE to hook it with the activator process.
Once this is done, you shall be able to break in your code anywhere. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With