How to use JRebel with NetBeans IDE and Tomcat
The goal of this document is to explain how to use JRebel technology with NetBeans IDE 7.2.1 and a local installation of the Tomcat 7 servlet container. JRebel is able to work with remote servers too, but this will be the subject of another tutorial.
Install the JRebel plugin into NetBeans
To install the JRebel NetBeans plugin, you only have to:
- Start NetBeans IDE.
- Go to the Tools > Plugins menu and install the JRebel NetBeans Plugin;
- Once the JRebel plugin is installed, you’ll have to restart the IDE.

Activate your JRebel free license
Visit https://my.jrebel.com/register and create a free account. You can connect through your Facebook or Twitter account too, it’s free.

- Scala: for Scala developments;
- OSS: for Open Source software;
- Social: for non-commercial projects;


PS 2: ZeroTurnaround (the creators of JRebel) have plans to simplify the licensing procedure. Please see: http://zeroturnaround.com/jrebel/jrebel-licensing-gets-simplified/ for details, even though I’m not sure whether this also affects free licensing.
Enable JRebel into Tomcat


Start Tomcat. You will see JRebel messages in the Tomcat logs, something like this:
[2012-12-09 00:35:53] ############################################################# [2012-12-09 00:35:53] [2012-12-09 00:35:53] JRebel 5.1.0 (201210161346) [2012-12-09 00:35:53] (c) Copyright ZeroTurnaround OU, Estonia, Tartu. [2012-12-09 00:35:53] [2012-12-09 00:35:53] Over the last 4 days JRebel prevented [2012-12-09 00:35:53] at least 38 redeploys/restarts saving you about 1.5 hours. [2012-12-09 00:35:53] [2012-12-09 00:35:53] This product is licensed to Jonathan Lermitage [2012-12-09 00:35:53] for non-commercial use only. [2012-12-09 00:35:53] [2012-12-09 00:35:53] License acquired through myJRebel server. [2012-12-09 00:35:53] [2012-12-09 00:35:53] You are subscribed for the plan "JRebel Social Plan", [2012-12-09 00:35:53] subscription is for lifetime. [2012-12-09 00:35:53] next license check with the server is required by 2013-01-08. [2012-12-09 00:35:53] [2012-12-09 00:35:53] The following plugins are disabled at the moment: [2012-12-09 00:35:53] * Apache MyFaces plugin (set -Drebel.myfaces_plugin=true to enable) [2012-12-09 00:35:53] * Click plugin (set -Drebel.click_plugin=true to enable) [2012-12-09 00:35:53] * JRuby Plugin (set -Drebel.jruby_plugin=true to enable) [2012-12-09 00:35:53] * Jersey plugin (set -Drebel.jersey_plugin=true to enable) [2012-12-09 00:35:53] * Oracle ADF Core plugin (set -Drebel.adf_core_plugin=true to enable) [2012-12-09 00:35:53] * Oracle ADF Faces plugin (set -Drebel.adf_faces_plugin=true to enable) [2012-12-09 00:35:53] * RESTlet plugin (set -Drebel.restlet_plugin=true to enable) [2012-12-09 00:35:53] * Seam-Wicket plugin (set -Drebel.seam_wicket_plugin=true to enable) [2012-12-09 00:35:53] * Spring Data Plugin (set -Drebel.spring_data_plugin=true to enable) [2012-12-09 00:35:53] * WebObjects plugin (set -Drebel.webobjects_plugin=true to enable) [2012-12-09 00:35:53] [2012-12-09 00:35:53] #############################################################
This message indicates JRebel is correctly registered into Tomcat and your license is active. Otherwise, you would see a message that indicates you license is not validated.
Enable JRebel in a Web Application project

Deploy your project for the first time and visit a webpage, such as a Servlet that shows information. Return to the IDE and modify your Servlet code, save it, and refresh the webpage. The new content reflects your code changes.
Now, every time you have to remove, edit, or add logic (classes, configuration files, etc.) to your project, you only need to save your modifications. You don’t have to redeploy your project to see changes.
To finish, when JRebel is reloading stuff, you may see messages in the Tomcat logs, such as these:
[2012-12-09 00:50:20] JRebel: Reloading class 'fr.tikione.myfavs.WelcomeServlet'. [2012-12-09 00:50:20] JRebel: Reloading class 'fr.tikione.myfavs.UserSession'. [2012-12-09 00:50:20] JRebel: Reloading class 'fr.tikione.myfavs.WelcomeServlet$FORM_RESULT'. [2012-12-09 00:50:20] JRebel: Reinitialized class 'fr.tikione.myfavs.WelcomeServlet$FORM_RESULT'. [2012-12-09 00:50:20] JRebel: Reloading class 'fr.tikione.myfavs.WelcomeServlet$1'. [2012-12-09 00:50:20] JRebel: Reinitialized class 'fr.tikione.myfavs.WelcomeServlet$1'. [2012-12-09 00:50:20] JRebel: Reloading class 'fr.tikione.myfavs.dao.AccountController'.
Limitations
- JRebel has some limitations. They are explained here: http://zeroturnaround.com/software/jrebel/features/. Supported technologies (servers, Java EE components, IDEs, etc.) are shown here: http://zeroturnaround.com/software/jrebel/what-we-support/.
- If you use the hibernation feature of your operating system, you may have to restart your application server, otherwise the JRebel’s class reloading may not work (verified on Windows 7 with Tomcat 7.0.32, Oracle JDK 7u09, NetBeans IDE 7.2.1 and the JRebel 1.3 plugin based on the 5.1.0 JRebel framework).
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Anton Arhipov replied on Mon, 2012/12/10 - 12:02pm
Great write up! However, you shouldn't spend time on setting the -javaagent option manually, instead there's a toggle button that enables jrebel agent automatically if you start the container from inside IDE.
Jonathan Lermitage replied on Mon, 2012/12/10 - 2:31pm
in response to:
Anton Arhipov
I have some problems with this feature, that's why I preferred not to mention it yet. But you're right :)
[edit] Okay, I have re-registered my server into NetBeans, and the javaagent flag is now automatically added. Strange, but good news.
Jonathan Lermitage replied on Fri, 2012/12/14 - 9:36pm
in response to:
Jonathan Lermitage
Finally, I have understood my problem : to let the JRebel plugin to add the javaagent flag automatically, the registered server's property "Use IDE Proxy Settings" has to be checked. I had unchecked it on my previous installations, that's why it didn't work.
Anton Arhipov replied on Sat, 2012/12/15 - 8:32am
in response to:
Jonathan Lermitage
Interesting! This is very good to know!
Matt Coleman replied on Wed, 2013/02/06 - 12:48am
JRebels in NB seems interesting i agree with Anton..will try it soon
sell sheet design
Den Fletcher replied on Thu, 2013/02/07 - 5:18pm
Fortunately, it's not that hard to use JRebel for your online site or applications. I have successfully used it for different modules of my holiday rentals France travel website. There are a lot of tutorials about this and I was even able to find one specially designed for travel agencies. I am pleased with the results and I wasn't able to find any bugs so far. That's why I have recommended it ever since.
Maxime Olivier replied on Fri, 2013/05/17 - 7:57am
Hoping this feature will remain updated. Création de site
Regards from Switzerland
Maxime