JRebel How-to: Using JRebel with JBoss Developer Studio and JBoss AS 7.1

JRebel Tutorial: Using JRebel in JBoss Developer Studio

In this tutorial you will learn how to install, configure and use JRebel in JBoss Developer studio with JBoss application server v7.1.

 

Installation

  1. Open JBoss Developer Studio
  2. Open JBoss Central view (Help -> JBoss Central), if it isn’t already open
  3. Go to the Software/Update tab
  4. Type in “JRebel” in the Search box
JBoss Developer
  1. Click checkbox next to JRebel and click Install button - Install pop-up will appear
  2. Select “JRebel” and “JRebel for Java EE” plugins from the list
  3. Follow instructions and agree to the License Agreement

Once the installation is complete, restart the IDE in order for the changes to take effect.

After you restart the IDE, if you do now have JRebel license yet, the plugin will notify you about this sad fact and ask for registration. Click on the link in the red pop-up and proceed with the license setup.

Please see the reference manual for the license activation options.

 

Sample Project: Kitchensink

In JBoss Central view, in Project Examples area, under JBoss Quickstarts list, click Kitchensink. In the dialog that appears, click Finish and an example Maven project will be generated into the workspace. The default name for the project is jboss-as-kitchensink.

kitchensink-example

JRebel Configuration

Apply JRebel configuration to project

To configure project to work with JRebel:

  1. Open JRebel Config Center (Help -> JRebel Config Center)
  2. Click on the box next to jboss-as-kitchensink to add JRebel nature
eclipse-plugin-jrebel-projects-overview

 

Adding JRebel nature to the project will automatically generate rebel.xml configuration file and add it to the project. See reference manual for more information about the configuration file.

You can also configure JRebel to work with the project by right clicking on the project itself, scrolling down to the JRebel tab and clicking "Add JRebel Nature".

Server configuration

To configure server:

  1. Open JRebel Config Center (Help -> JRebel Config Center)
  2. Click on the checkbox next to the server to enable JRebel for the server
eclipse-plugin-servers-list

JRebel in Action

One you start the server with JRebel agent enabled, you should see JRebel specific messages:

 

jrebel-banner-1024x612

This is the JRebel Welcome Banner.  It details the version of JRebel you are currently using, whether there is an update, the kind of license you are using, how long until it expires, disabled plugins etc.

You will also see JRebel log messages showing what specific directories JRebel is monitoring, listed in rebel.xml configuration file.

jrebel-monitoring-dirs-log

Now let's make some changes!

This is the current new member registration form with sections allotted for name, email and phone number:

Add a new section for address:

  1. Open up the Member.java file and add the new address field with the appropriate getter and setter.  We want to make it a String with some restrictions.

  1. Open up the index.xhtml file and add the address input to the Member Registration form, "reg".

  1. In the same file, add the address column to the Members data table.

  1. Now, in order for John Smith to be correctly inserted into the database, navigate to your import.sql file and add "address" to the Member constructor and an address to the Member John Smith.

  1. Refresh your browser and you should see the updated form object and data table. 

In the console you'll notice that a few things were logged.   JRebel reloaded the Member class and printed a notification about the new non-static field "address" in the Member class.  The Weld and Hibernate framework integration then kicked in.  These plugins allowed JRebel to reconfigure the newMember and null beans and the Hibernate SessionFactory.

Add some new members:

Now that we have some new members to work with, let's expand on our current REST URL so we can look up individual members using an email address:

  1. Open up MemberResourceRESTService.java and add the new method lookupMemberByEmail.

  1. Luckily, there is already a findByEmail method in the MemberRepository.java, so we can skip that step.

  1. Open up index.xhtml. At the bottom of the file add a new note and url to the footer, like so:

  1. Save and refresh the browser

As you can see in the console, JRebel reloaded and reinitialized the MemberResourceRESTService class and reconfigured some beans.

Now give it a try! Add one of your current member's email at the end of the current url. You'll see the requested member's information appear in the browser.