Since PWS migrated it's users to Diego, it is now possible to access an application instance directly via SSH or indirectly via an SSH tunnel. For Java applications, this can be used to connect and execute command line tools or to connect remotely via tools like jvisualvm. The two sections below describe how to do both of these tasks.
To access the container to debug from the command line, you'll need to perform the following steps.
export JAVA_HOME=$HOME/app/.java-buildpack/open_jdk_jre/ export PATH=$PATH:$JAVA_HOME/bin
These two commands will setup the environment.
To access your application remotely, you'll need to perform the following steps.
For more details on connecting via JMX, please see the Java build pack documentation.
If you have access to YourKit, which is a commercial Java Profiler, you can also use that to debug your Java applications. The process is very similar to what's described for remote JMX debugging above but uses a proprietary protocol to communicate over the SSH tunnel. Instructions for configuring can be found in the Java build pack documentation.
Please be aware that applications with a large heap, over 2GB, will not be able to generate heap dumps. This is because the JVM will write the heap dump information to the container's file system and the maximum size of the container's file system is 2GB. If your application's heap is greater than 1GB, don't forget to set the -k argument to cf push to increase the disk size from 1GB to 2GB, as 1GB is the default size for the container's file system.