New Cloud Foundry Java Buildpack Improves Developer Diagnostic Tools

December 8, 2015 Ben Hale

sfeatured-clouds-tools-powerOver the last couple of months, the Cloud Foundry Java Experience team has improved a number of features for applications running in production. We’ve added support for Luna HSMs, an improved memory calculator, support for the Dynatrace and Introscope APM providers, and made many other minor improvements. Being that I’m a developer at heart, I’m happy to announce the developer-focused improvements found in the latest Cloud Foundry Java Buildpack release.

Cloud Foundry Java Buildpack v3.4 takes advantage of the SSH tunneling support provided by Pivotal Cloud Foundry 1.6+, and enables JMX, Debugging, and Profiling connections to application instances. There are times when you just need to see what’s going on inside the container. Or you may just be tired of using your log files for debugging, or making System.out.println(); calls in your code everywhere instead of using a proper debugger.

You might ask, “Cloud Foundry is a production deployment platform, and not a development platform, so why are we discussing developer-oriented features? Isn’t Cloud Foundry supposed to work on the idea of immutable infrastructure, and now we’re talking about SSH access?” The simple answer is that these are troubleshooting and diagnostic tools only, used to help you monitor, debug, and diagnose performance issues on standby, staged, or test application instances. Since restaging is required to turn on these features, you’re probably not going to use these tools against “live” application instances that are servicing actual production traffic and users.

In order to make an SSH connection to your application, you’ll need to have both Pivotal Cloud Foundry 1.6 and SSH access enabled. Use the following commands to configure and test this:

$ cf push -b https://github.com/cloudfoundry/java-buildpack.git#v3.4 --no-start
...
Done uploading
OK
$ cf enable-diego java-main-application
Diego support for java-main-application is set to true
$ cf enable-ssh java-main-application
ssh support is already enabled for 'java-main-application'
$ cf start java-main-application
...
state since cpu memory disk details
#0 running 2015-12-01 03:24:29 PM 0.0% 233.5M of 512M 168.2M of 1G
$ cf ssh java-main-application
vcap@6bl1s80i6sm:~$

If you are able to get a shell prompt in your application’s container, you’re ready to examine some developer diagnostics.

JMX

To enable JMX access to your application, execute the following commands:

$ cf set-env java-main-application JBP_CONFIG_JMX '{enabled: true}'
Setting env variable 'JBP_CONFIG_JMX' to '{enabled: true}' for app java-main-application in ...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect
$ cf restage java-main-application
...
state since cpu memory disk details
#0 running 2015-12-01 03:50:32 PM 0.0% 317.8M of 512M 168.2M of 1G
$ cf ssh -N -T -L 5000:localhost:5000 java-main-application

Once the SSH tunnel has been created, your JConsole should connect to localhost:5000 for JMX.

Additional configuration information can be found in the Java Buildpack JMX Framework documentation.

image02

Debugging

To enable debugging access for your application, execute the following commands:

$ cf set-env java-main-application JBP_CONFIG_DEBUG '{enabled: true}'
Setting env variable 'JBP_CONFIG_DEBUG' to '{enabled: true}' for app java-main-application in org bhale / space development as bhale@pivotal.io...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect
$ cf restage java-main-application
...
state since cpu memory disk details
#0 running 2015-12-01 03:58:03 PM 0.0% 341.8M of 512M 168.2M of 1G
$ cf ssh -N -T -L 8000:localhost:8000 java-main-application

Once the SSH tunnel has been created, your IDE should connect to localhost:8000 for debugging.

image01

Additional configuration can be found in the Java Buildpack Debug Framework documentation.

Profiling

To enable YourKit profiling access for your application, execute the following commands:

$ cf set-env java-main-application JBP_CONFIG_YOUR_KIT_PROFILER '{enabled: true}'
Setting env variable 'JBP_CONFIG_YOUR_KIT_PROFILER' to '{enabled: true}' for app java-main-application in org bhale / space development as bhale@pivotal.io...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect
$ cf restage java-main-application
...
state since cpu memory disk details
#0 running 2015-12-02 11:19:31 AM 124.6% 316.5M of 512M 172.4M of 1G
$ cf ssh -N -T -L 10001:localhost:10001 java-main-application

Once the SSH tunnel has been created, YourKit should connect to localhost:10001 for profiling.image00

Additional configuration can be found in the Java Buildpack YourKit Profiler Framework documentation.

Thanks to Contributors

I’d be remiss if I didn’t mention that these features were initially driven by community contribution. Mike Youngstrom asked for debugging support to start the ball rolling, and James Bayer pushed us to deliver more features that he’d heard from customers, resulting in the JMX and profiling support. As the lead of the Java Experience team, this is the kind of community involvement I love. So while you’re testing out these new features, keep thinking of ways that we can make you more productive. When you come up with something, open an issue on the GitHub repo and we’ll take a look.

Conclusion

Together with the capabilities already in the Java Buildpack, these updates mean that Cloud Foundry offers the leading Java SE experience in the cloud. Whether you’re developing Grails, Groovy, Java Main, Play Framework, Spring Framework / Spring Boot, or Servlet applications, Cloud Foundry offers a superior experience for Java SE developers, from desktop to cloud.

About the Author

Biography

More Content by Ben Hale
Previous
Two Free Pivotal Labs Services For Startups—Now In Denver & Boulder
Two Free Pivotal Labs Services For Startups—Now In Denver & Boulder

Pivotal Labs is offering two free, no-strings-attached programs to help startups—Product Office Hours and P...

Next
NBCUniversal Uses Training To Accelerate Cloud-Native Journey
NBCUniversal Uses Training To Accelerate Cloud-Native Journey

Like every other traditional media and entertainment company, NBCUniversal finds themselves with a dizzying...

×

Subscribe to our Newsletter

Thank you!
Error - something went wrong!