How to debug CDAP sandbox with IntelliJ on mac

Viewed 388

I am trying to debug CDAP code and plugin code

I have tried several options to run the CDAP sandbox:

https://docs.cask.co/cdap/5.1.0-SNAPSHOT/en/developer-manual/getting-started/sandbox/docker.html

The sandbox runs and the stout logs say port 5005 is exposed for debugging

Starting CDAP Sandbox ...Listening for transport dt_socket at address: 5005

docker ps has two other ports: 0.0.0.0:11011->11011/tcp, 0.0.0.0:11015->11015/tcp cdap-sandbox

When I configure IntelliJ debugger to 11015 it seems to have no problem but breakpoints don't catch the running of code.

I tried running CDAP sandbox on virtualbox and using 192.168.99.100 but I still cant catch breakpoints with the remote debugger

I also tried adding 5005 to exposed docker ports 0.0.0.0:5005->5005/tcp and configuring intellij to do the same. Intellij was not able to connect to remote 5005

How do I debug cdap sandbox with intellij?

3 Answers

Problem is with the functions.sh file in bin directory. By default it binds the listening port to localhost.

To fix it:

Find the line:

"CDAP_SDK_OPTS+=" -agentlib:jdwp=transport=dt_socket,address=localhost:${__port},server=y,suspend=n"

and change it to something like (remove localhost:):

"CDAP_SDK_OPTS+=" -agentlib:jdwp=transport=dt_socket,address=${__port},server=y,suspend=n"

Have you started CDAP with --enable-debug flag?

Our documentation here will help you with starting CDAP in debug mode.

Additionally you might find our Testing and Debugging documentation helpful.

  • Start the CDAP sandbox in debug mode.
bin/cdap sandbox start --enable-debug
  • In intelliJ goto Run -> Edit Configurations -> Add New Configuration -> Remote
  • Specify the Configuration name, enter the host and port(5005 for debugging cdap).
  • Select your maven module in Use module classpath input configuration and hit Apply

  • Now to debug hit the debug button and you are good to go.

Related