Open the code, that is running on a remote server, in intellij select edit configurations select remote while adding a new configuration - save it with a name. copy paste text in - command line arguments for running remote jvm
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
while submitting the new job go with ONE OF THE four options
check if the program/application is triggered by a shell script ... if yes ... does it have JAVA_OPTS being used while running the program. If yes, run the following commands on shell before running the program.
NOTE : Generally both JAVA_ARGS and JAVA_OPTS are used ... so you can use either of them.
*probably ...
JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
export JAVA_OPTS
check if the program/application is triggered by a shell script ... if yes ... does it have JAVA_ARGS being used while running the program. If yes, run the following commands on shell before running the program.
the below definitely works -
JAVA_ARGS="${JAVA_ARGS} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
export JAVA_ARGS
If you are running a regular program- being run from the shell, use the following command pattern
Two points here: No spaces in the runjdwp option.
Options come before the class name. Any arguments you have after the class name are arguments to your program!
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
https://stackoverflow.com/questions/975271/remote-debugging-a-java-application
//3.
- snappydata -
To debug code invoked by server/locator/lead in snappydata - use conf/servers<locators,leads> file and replace 'localhost' at the EOF with the following line :
localhost -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
NOTE: I believe address(port number) can be used once (for a specific JVM). Since one configuration can be run at a time in intellij, i don't see how multiple JVMs can be debugged simultaneously, may be by mulitple debug windows running different remote configurations.
To debug code invoked by snappy-sql sql prompt, use the JAVA_ARGS way given above (set the JAVA_ARGS and then run ./bin/snappy-sql). connect to the client before running the debugger in intellij
//4.
Once the application/program to be debugged is running, run the debug configuration you created.
https://github.com/getsandbox/sandbox/blob/master/scripts/linuxEmbeddedRun.sh
//5. for spark shell :
./bin/spark-shell --master local[*] --driver-java-options -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 --conf spark.snappydata.connection=localhost:1527