unable to debug play framwork 2.x in Scala IDE - scala

I have a project with java & scala classes. I want to debug this project in Scala IDE.
I run this command at my application end
./activator -jvm-debug 9999 run
And debug in Scala IDE as Remote Java Application with localhost & port 9999.
It did not stop at my breakpoints.
Any pointers on this.

In my build.sbt
fork in run := true
I changed it to false. Now its working.

Related

how to debug scala sbt project in vs code

I am trying to debug sbt project in vs code. I have downloaded vs code extension name scala metals. How to explicitly add build.sbt folder path in scala metal.
How to explicitly add build.sbt folder path in scala metal
Open the root of your Scala project via VSCode, and Metals should detect your build.sbt and ask you if you want to load it. Otherwise you can do it explicitly from the Command Palette (Ctrl+Shift+P) and write "Metals Import Build"
how to debug scala sbt project in vs code
Not sure how to do it via metals. But the way I do it, is to open sbt myself from the terminal, via sbt -jvm-debug 5005. Then I attach VSCode remote debugger. You'll have to install "Debugger for Java" VSCode plugin too.
Here is the official documents: https://scalameta.org/metals/docs/editors/vscode.html,
See the "Running and debugging your code" sections.
But I found it's hard for me to debug the web project based on play framework.
So I use inntelij instead.
Start the project in sbt with: sbt --jvm-debug 5006
You can run it in the terminal:
After entered sbt, type "run" to start the proejct.
Add a new debug configuration, set port to: 5006
And then click "run->debug...", you can add the breakpoint.

How to specify "fork in Test := false" from command line rather than from build.sbt in a play framework based project

To keep the question as short as possible I just need to know if there's a way to set fork to false directly from the command line when launching activator instead of hard coding it as follows "fork in Test := false" from under build.sbt in a play-framework 2.4 based project.
__________________All below is for further context___________________
I'm maintaining a "legacy" project based on play framework version 2.4, and been trying to configure my IntelliJ environment to enable debugging with unit tests. To achieve this I created 2 run configurations, the first launches activator in debug mode and pipes all its output to IntelliJ console, the second attaches the debugger to the formerly launched jvm. I'm then free to run and debug any tests as I please from activator's prompt.
In order for the debugger to work though, I have to add the following to my build.sbt:
fork in Test := false
which allows for debugging with my IntelliJ project setup, since I have it properly configured to take my "conf/test-config.conf" into consideration when launching activator. But when I simply run "activator test" from a native command line console, with the fork option set to false, activator ignores my test-config.conf file (obviously with configurations tuned for unit tests) and instead loads the original app config file "application.conf" causing my tests to fail with all sorts of conflicts. This happens even with the below configuration in my build.sbt:
javaOptions in Test += "-Dconfig.file=conf/test-application.conf"
Commenting out "fork in Test := false" fixes the problem when I launch the tests from a native console (the unit tests run properly), my IntelliJ launch configuration also succeeds to run the tests but the problem is it loses its ability to debug the code, which is actually the whole point in the first place.
Here's the command I'm currently using from IntelliJ to launch activator in debug mode:
java -Dactivator.home=<activator-home-path> -Xms1024m -Xmx1024m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m -Dsbt.override.build.repos=true -Dconfig.file=conf/test-application.conf -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9990 -jar <activator-jar-path>
Simply use the following command when using sbt:
sbt "set fork in Test := false" test
For activator, you can try the following:
Add this to your build.sbt:
fork in Test := Option(System.getProperty("fork")) match {
case Some("false") => false
case _ => true
}
And then sumply run the following command:
activator -Dfork=false test

how to debug play framework 2.5 in eclipse

Enviroment
OS : OS X EL Capitan
IDE: Luna Release (4.4.0)
Activator : activator-dist-1.3.10.
My step.
--> But at the last step, I can't connect to vm. Wating for vm connect at port 999.
Please help me !
In your debug configuration you have to set Connection Type to Standard (Socket Attach) (in the screenshot you have selected Standard (Socket Listen).
open your eclipse
Navigate to Help->eclipsemarketplace
Search scala
Then install two plugins:-
1) ScalaStyle 0.7.0
2) Scala Ide 4.2.x
run below command in console from your project directory
Note: before debug first run this command
activator -jvm-debug 9999 run
now right click on project
go to
Debug as -> debug configuration click new and insert project name
set port number to 9999
now select Scala debugger(socket attach)(Scala debugger will come only if you have installed those plugin mentioned above) from dropdown
and click on debug

Scala / sbt: How to stop at breakpoints in Eclipse

I am trying to debug my Scala application when running tests using sbt. I have added the following lines to build.sbt:
javaOptions in test ++= Seq(
"-Xdebug",
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001"
)
I have also set breakpoints in Eclipse and configured a remote debugger for that port 8001.
When launching the tests from command line, the remote debugger is start correctly:
Listening for transport dt_socket at address: 8001
But then the execution of the tests does not suspend, as expected, and so I am not able to connect the remote debugger. Instead, the tests are simply run.
Any ideas what I might be doing wrong here? How can I debug the sbt tests using breakpoints in Eclipse?
The following worked for me (not tested in test, but probably work the same way). In this example, I used a project generated by udash-generator (0.3.1).
$ sbt
> set fork := true
> set javaOptions ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8001")
> run
I used eclipse (Neon with ScalaIDE 4.4.1, Scala 2.11) (sbt eclipse with-source=true) and added a breakpoint to the com.example.rpc.ExposedRpcInterfaces.hello(name: String) method.
Created a run configuration:
Started the launch configuration (the eclipse debugger) and opened browser with http://localhost:8080/#/rpc, started typing to the textfield and eclipse stopped at the breakpoint.
I am not sure what was different for you, as it seems you were also forking a new JVM for tests. I can try your setup if you provide more details which test framework you were using.

Scala Play 2.3 InteliJ 14 *community edition - is it possible to run project without cmd line activator command

From http://blog.jetbrains.com/scala/2012/12/28/a-new-way-to-compile/ I understand that Intellij is using sbt to build - so thats 1x build
At the moment I run a separate command line task to run my project -
./activator -jvm-debug 5000 -Dhttp.port=9000
So each code change gets compiled twice (once by InteliJ; once by activator)
Is there a way to use the InteliJ build artifacts when I run, so the code is only compiled once?
Is using the Terminal window in InteliJ any different from a normal terminal window?
The versions I'm at are:
Java 7
Play framework 2.3.4
SBT 0.13.1
InteliJ 14 (community edition)
Thanks
Brent
Yes it's definitelly possible.
Install Play 2.x plugin (with dependencies) and add the run configuration dedicated for Play 2 (note in Intellij 14 Play2 support is combined within the Scala plugin)
Menu > Run > Edit configurations... > Add new configuration (plus icon in the corner) > Play 2 App
After saving you will be able to run your app (also in debug mode) within IntelliJ - i.e. via
Menu > Run > Debug 'Your Project'
btw, you can remove Make (before launch) from there, SBT should handle builds properly without Idea's support
See sample shot