In this tutorial we will show how to integrate and test JRebel Eclipse plugin with JBoss AS 7.1.1 platform.
For those who have never heard about it, JRebel is a JVM-plugin that makes it possible for Java developers to instantly see any code change made to an app without redeploying. JRebel lets you see code changes instantly, versioning classes and resources individually and updating one at a time instead of as a lump application redeploy. When developers make a change to any class or resource in their IDE, the change is immediately reflected in the deployed application, skipping the build and redeploy phases.
Now let’s get started with the installation. At first install JRebel on your Eclipse environment. Search for “JRebel” in Eclipse market place and install it.
Once installed and restarted Eclipse, you will be prompted to get a license to work with JRebel.
Let’s start with an evaluation (1) which will take you to a registering form where, once completed, you will quickly get an Activation License which needs to be pasted (2) into the JRebel activation window.
Once unlocked JRebel, switch to the JRebel Config Center (Window > Show Perspective > Other ) and activate JRebel on your JBoss AS 7.1.1 installation (Note this will disable automatic deployment of applications).
We’re almost done! Now let’s create a sample Web application with a quintessential Servlet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<h1>Hello world </h1>"); out.flush(); out.close(); }
Now add JRebel nature to your project, by right clicking on the project and picking up this option from the JRebel menu:
Fine. Now start JBoss AS 7 and verify that the server is correctly bound to JRebel (You should be able to see the following logs at server start up)
[2013-04-04 17:20:20] ############################################################# [2013-04-04 17:20:20] [2013-04-04 17:20:20] JRebel 5.2.0 (201302272115) [2013-04-04 17:20:20] (c) Copyright ZeroTurnaround OU, Estonia, Tartu. #############################################################################
Now let’s test out sample Servlet as it is:
If you paid attention to your logs, you should have found the following INFO which informs us that JRebel has started monitoring a folder (beneath your user home folder) for changes in your application:
16:02:01,243 INFO [stdout] (MSC service thread 1-5) [2013-04-04 16:02:01] JRebel: Directory 'C:\Users\emaifro\workspace\SampleWebApp\WebContent\WEB-INF\classes' will be monitored for changes.
Now let’s apply a trivial change to your Servlet, by modifying the output message produced by it:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("<h1>Hello world from JRebel</h1>"); out.flush(); out.close(); }
Now save the Servlet (and don’t deploy it!). Check again on the browser for your Servlet:
As you can see from the logs, the Servlet has been reloaded, without the need to redeploy the whole application:
16:04:15,015 INFO [stdout] (http-localhost-127.0.0.1-8080-1) [2013-04-04 16:04:15] JRebel: Reloading class 'com.sample.Test'.
Thanks to Oliver White from ZeroTurnAround for providing the info for setting up this tutorial.