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 Type: Standard (Socket Attach)
Host: localhost
Port: 4000
Select "Apply" and then "Debug"
3. Create breakpoints in your code and start the Jetty container:
container:start
Doesnt work for me.
ReplyDeleteWhen I run container:start I'm receiving this error (I'm brazilian):
Erro: Não foi possível localizar nem carregar a classe principal
Error: Could not find or load the main class
How Can I do to solve this?
The main class is defined by extending App (i.e. Boot extends App). Make sure you have one of those and reference it from your SBT file: mainClass in assembly := Some("Boot")
ReplyDeleteIn Gradle it looks something like this: mainClassName = "Boot"