Friday, 31 January 2014

Scala: Remote debugging in SBT's Jetty container

The following will attach your Scala source code to your webapp running in Jetty.

Configuration for remote debugging in SBT's embedded Jetty is not much different Maven's Jetty plugin. Here I used Scala 2.10, SBT 0.12 and dependency "jetty-webapp" 8.1

1. Export JVM debug parameters

$ export SBT_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"

                   Note: Change parameters "suspend" and "address" to your own needs.

2. Start SBT (sbt) and configure your IDE to connect to the port SBT is listening on. In Eclipse, for example, would be something like this: 

"Run" > "Debug Configurations" > "Remote Java Application"

Create a new configuration and enter the following:

Connection TypeStandard (Socket Attach)

Select "Apply" and then "Debug"

3. Create breakpoints in your code and start the Jetty container: 


No comments:

Post a Comment