You can debug an application running on a Cloud Foundry container that uses the community Java buildpack.
-
Download and Install the Cloud Foundry Command Line Interface
-
Log On to the Cloud Foundry Environment Using the Cloud Foundry Command Line Interface
To debug an application using the community Java buildpack, you need to open a debugging port on your Cloud Foundry container and open an SSH tunnel that will connect to that port.
-
To open the debugging port, you need to configure the
JAVA_OPTSparameter in your JVM. From the cf CLI, run:cf set-env <app name> JAVA_OPTS '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000' -
To enable SSH tunneling for your application, run:
cf enable-ssh <app name> -
To activate the previous changes, restart the application by running:
cf restart <app name> -
To open the SSH tunnel, run:
cf ssh <app name> -N -T -L 8000:127.0.0.1:8000Your local port 8000 is connected to the debugging port 8000 of the JVM running in the Cloud Foundry container. Also, 8000 is the default port.
The connection is active until you close the SSH tunnel. When you finish debugging, close the SSH tunnel by pressing [Ctrl] + [C] .
-
Connect a Java debugger to your application. For example, use the standard Java debugger provided by Eclipse IDE and connect to
localhost:8000.