Missing 'debug' command from Play 2.0 installed from Typesafe - scala

I installed play 2.0 from the typesafe stack.
However, when i try to run sbt debug run it gives me the error:
[error] Not a valid key: debug (similar: idea)
Any suggestions on how to run a debug server?

In order to debug with the sbt command instead of the play command, you have the option to set the env. variable SBT_OPTS with the classical
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9999
Source : https://groups.google.com/forum/?hl=fr&fromgroups#!topic/play-framework/-RVlEh8S2F4

I spent quite some time on this tonight. Hope my experience helps.
And as many of you I am encountering same issue that debug is not recognized under sbt. The easiest way of course is to follow the documentation. install the Play standalone and run the play debug run command, and then debug remote java application using the 9999 port.
but #Julienlafont 's solution did workout as well (I had the confusion at first as well). The key is to understand the whole process. Play web server is still served through port 9000. but port 9999 is opened as debug port to let IDE connect to , this is important.
I guess the reason why debug is not recognized is because it is not a sub command at all. it is indeed a couple of JVM arguments as #Julienlafont point out. so the what play command did is simply wrap the JVM argument for you. note once you enter the play console, the debug extension wont be recognized, because its essence is a couple of JVM arguments.
so go ahead set that JVM argument, once you see the hint , you are done with opening the debug port. run your server and finish the remaining part.

Related

Debugging a software verifier written in sbt on Intellij Idea

I'm working with Stainless, a software verifier for Scala programs. I would like to debug the verification process of a sample programme on Intellij Idea. On a previous post, I solved this integration problem for an interactive theorem prover. But now, I'm facing two problems:
Apparently, the verification software runs at compile time. That is, I enter in the sbt console and run the compile command and then the verification process seems to be done. You may try this with this verified example. This situation is new to me, since I was used to debug the program while executing.
All the setup in the sbt files of the example above (see for instance this file) seem to refer to online content, while I want to make sure that I work with my local copy forked from the original repository of the verifier.
None of the configurations I tried worked. Can you help me out of this problem?
Details
This is the current configuration page of stainless.
If the verification runs within the sbt process, you can debug it by attaching the debugger to sbt. IntelliJ makes this easy with the embedded sbt shell:
open the sbt shell toolwindow
click the "attach debugger to sbt shell" button on the left
set breakpoints in your code
run the task

Breakpoints dont work Remote debugging Play/Activator

I just started with the Play Framework but to learn these kind of things it is amazingly convenient to be able to use breakpoints.
Now I figured quickly that when I run 'activator -jvm-debug 9888' I can connect my Intellij CE 14 to its debugger. That seems to work, console gets nicely printed on the webui 'standard out' but not in my Intellij even when it says it connected.:
'Connected to the target VM, address: 'localhost:9888', transport: 'socket''
But that is truly about it, no console messages are show or breakpoints get hit inside intellij
Anyone had the same problem before and knows how to solve it? (Googling didn't find me the answer!)
Greets
In your build.sbt try to add this line (with a capital T!):
fork in Test := false
For info see http://www.scala-sbt.org/0.13/docs/Forking.html

Attaching a Remote Debug session to Spark from Eclipse Scala IDE

I've been wracking my brain over this for the last two days trying to get it to work. I have a local Spark installation on my Mac that I'm trying to attach a debugger to. I set:
SPARK_JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
Then I submit my job to spark-submit and launch my debug configuration in eclipse which is configured as a Socket Attach Remote Debugging session. The debugger attaches, my job resumes and executes, but none of my breakpoints are ever hit, no matter what I do.
The only way I can get it to hit a breakpoint is by attaching to a spark-shell, creating a Java Exception breakpoint and issuing
throw new java.lang.Exception()
The debugger will not stop at normal breakpoints for me.
I created a standalone Hellow World scala app and was able to attach to it and have it stop at a regular breakpoint without any issues.
Environment: Mac OS, latest Eclipse, latest Scala IDE, Spark 1.3.1, Scala 2.10.5
Thanks in advance.
I had a similar issue and there were 2 things that fixed my problem -
1. The .jar file and source not a little out of sync for me , so had to recompile and redeploy.
2. Next On the JAVAOPTS I had a suspend=n.
After correcting these two it worked for me .

Debug Playframework 2.0 in Eclipse

There's no eclipse folder in project folder after 'play eclipsify'. How to debug this project use eclipse with JPDA?
Since play 2.0, only thing need to do to debug a project is run project in console 'play debug run' and create a new debug conf of remote java application with port 9999
Exactly as fxp has said, in play 2.2.x you should do the following:
Type in the play console play debug run
In eclipse, right click over your project and go to Debug As, and then click on Debug configurations..
In Debug configurations screen, go and click to Remote Java Application.
Put 9999 in the port input text (*)
(*): when you execute play debug run, look the print information for the port number. Probably the first message will be
Listening for transport dt_socket at address: 9999
In Play 2.3.x, you need to start the application with:
activator -jvm-debug 9999 run
Then follow all the other steps in the other answers.
Setting up your preferred IDE
The socket port for debugging is 9999 in play 2.0
Another thing, you might need to create a unit test in Play to get the debug running.

Is it possible to debug PL/Java (ideally from Eclipse)?

Although I found PL/Java a powerful add-on for PostgreSQL, I couldn't find a way of remotely debug the clases loaded on the PSQL DBMS.
Is this possible to achieve?
Thanks in advance!
I suppose you could set pljava.vmoptions to enable debugging and include a port number to listen on, and then use Eclipse's "debug remote application" launcher to connect to it.
So a JVM option -agentlib:jdwp=transport=dt_socket,suspend=n,address=localhost:55000 will make the JVM listen on port 55000 for debuggers. You then open the "Debug configurations.." dialogue in Eclipse, right click "Remote Java Application" in the launch types pane on the left and update the connection properties on the right to use port 55000. You should connect up the debug launcher with a project as well, to pick up that project's class path and sources.
Note I haven't actually tried this in postgresql, but this corresponds to how I always used to run JBoss from a shell script rather than from within Eclipse.
I needed a slight change to the option line. The working one is-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=localhost:8000. Without the server=y part, the debugger complains about missing transport. With the above, everything worked.