A couple of days ago, I’ve attended Philly JUG for a talk titled Non-stop Java Development, presented by Ivo Magi of Zero Turnaround. The focus was on their product JavaRebel and how it can speed up development by cutting down on deployment time and on server restarts.
So what problem is JavaRebel trying to solve? When you make code changes in the application you go through the usual cycle of:
{make-a-change} -> {waitFor: build-deploy-serverRestart} -> {check-the-change}.
JavaRebel claims to eliminate the second step of waiting for build/deploy and the need for restarting application server for the code changes to take affect.
No need to mention that I’m a big fan of open source model, JavaRebel is not in that category, it is a commercial tool. The presenter discussed about the available non-commercial options and why this product is better than the existing tools. As far as the available options (or approaches) there are two major ones — hot deploy and hot swap.
Hot deployment: When a class is changed build-deploy takes place without a need for a container restart. My experience with this so far has resulted in varied degrees of success. It works fine for a few times but had to restart the container/server after a few changes. (I also don’t have enough confidence that it can work effectively in a clustered production environment, but that is not the concentration of this post, it is the development time and how to minimize the wait time). OSGi approach is perhaps very similar to hot deploy except that it works at granular level on individual bundles, as opposed to updating the entire application.
Hot swap: An ability to change the class while a JVM is running, without the application ever noticing that. This is useful for the quick reload of classes during the debug time. If you change some functionality in the existing methods that works fine, but if you add a new method to a class or if you add a new class the changes are not detected.
Another option is that you may try your luck with some class loader hacks — loading the changed class in a different class loader, etc. I never tried it. Again, if anybody used this approach successfully please provide your comments. There are a few frameworks that were mentioned in the presentation that use this approach, I can only remember Tapestry at the moment.
As far as JavaRebel goes it extends the hot swap functionality. It is implemeted as a JVM plugin (-javaagent). In simple terms an agent in JVM works like an interceptor in front of your main method. The -javaagent command line option is used to register custom instrumentation plugins. What I understood from the talk is that JavaRebel works at the class loader level, it doesn’t create new ones but extend the functionality of the existing class loaders.
Saving the application state after class reloads saves quite a bit of time, especially if you are working on a work flow kind of application and you are testing some step 8 of 10. You can continue your test from where you stopped and doesn’t have to go back to step 1.
JavaRebel also seems to have some plugins to support popular web frameworks. I remember Spring, Guice and Struts were mentioned.
Obviously, I haven’t tried the tool so I can not make any recommendations. Try it for yourself and see if it suits your needs.
Follow on Twitter
#1 by Brian Hurley on June 25th, 2009
Quote
I’ve been using JavaRebel since they presented at JavaMUG.org earlier this month and I love it. It has cut my development wait time down by several minutes per day. That may not sound like a lot of time but the longer that I wait on something the more likely I get distracted and go off working on email/blog/reading/whatever. I feel that this has increased my development focus while I’m coding and therefore has the effective benefit of increasing my productivity by probably several hours per day.
[Reply]
#2 by Dave Booth on June 26th, 2009
Quote
Great post Surya – If you get the chance to try out JavaRebel, let me know how it goes, and if there’s anything we can do to make it better. Did Ivo also mention that we’re working to take JavaRebel technology into production environments, for easy upgrades and rollbacks of live apps?
[Reply]
Surya Suravarapu Reply:
June 26th, 2009 at 9:25 am
Dave, thanks. I’m planning to try JavaRebel soon. Yes, I heard about LiveRebel.
[Reply]
#3 by florin on June 28th, 2009
Quote
I’ve been using JavaRebel for about 3 years now. By all means, I would never go back. Even before JavaRebel, I found it offensive for Sun not to provide such a development capability – add a -dev flag to the java executable and bring relief to millions of developers. Well, Sun never bothered to do so and I will never forgive them for that.
[Reply]
Surya Suravarapu Reply:
June 28th, 2009 at 1:02 pm
Oh, I’m not aware that JavaRebel is around for that long. I’ve been hearing about it for the last 6 months or so. I hear you, I wish Sun should have done something to address the productivity issue.
[Reply]
#4 by bob on June 29th, 2009
Quote
JavaRebel is a trivial classloader implementation. Paying for it is really ridiculous.
[Reply]
#5 by Jevgeni Kabanov on June 29th, 2009
Quote
@florin
3 years is overdoing it
1.0 final was released in December 2007.
@bob
http://www.zeroturnaround.com/javarebel/faq/#How_does_JavaRebel_work
[Reply]