How to install and use JavaRebel in IBM WebSphere with Rational Application Developer or Eclipse

How to install and use JavaRebel in IBM WebSphere with Rational Application Developer or Eclipse

IBM WebSphere application container features one of the longest startup and redeploy times in development. In a survey we conducted, developers estimated spending approximately 30% of their coding time (almost 250 hours annually, per developer) waiting for applications to redeploy. JavaRebel eliminates 80% of redeploy situations, and it’s easy to get started. In the embedded video you can take a quick look at how coding looks when using JRebel.

This tutorial assumes that you are using Eclipse 3.x or Rational Application Developer 7.x with WebSphere 6.x or later. Most of the steps will be applicable to other versions as well, but it may look different from the screenshots included.

Contents:

STEP 1: Install JavaRebel

The latest stable version of JavaRebel can be downloaded here. Unpack it to a directory of your choice.

2009-07-03_124429

It is useful to define an environment variable called REBEL_HOME pointing to the directory you choose. In Windows you can do this by going to Control Panel » System » Advanced » Environment Variables » System Variable » New.

2009-07-03_134354

Now navigate to the directory where Java is bundled with IBM WebSphere. If you have a standalone installation it’s %IBM_HOME%\WebSphere\AppServer\java\bin. If you have it installed as part of RAD7 it should be %IBM_HOME%\SDP\runtimes\base_v61\java\bin. Run the following line in the console:

java -jar %REBEL_HOME%\javarebel.jar

2009-07-03_140819

STEP 2: Installing JavaRebel Eclipse/RAD IDE plugin

The JavaRebel Eclipse IDE plugin was introduced with JavaRebel 2.0 and makes configuring and using JavaRebel considerably easier. You can install the plugin by going to Help » Software updates » Available software » Add site and use the http://www.zeroturnaround.com/update-site/ URL as the update site.

2009-07-03_130819

STEP 3: Make a rebel.xml for your application

In order to do it’s magic, JavaRebel needs to know where your classes and resources are.  We’ll use a rebel.xml configuration file to tell it.  This is mandatory when you deploy your app as a WAR/EAR. You’ll need to have one rebel.xml file per module. This includes both web and EJB modules. The rebel.xml configuration file should be placed in your WEB-INF/classes directory in the case of a web module and in the jar root in the case of an ejb module. Put it in the root of a source or resource folder in your project (the same place where the .properties files are).

If you use Maven you can use the JavaRebel Maven plugin that will generate the rebel.xml in accordance with the module pom.xml as described in the Maven Plugin configuration manual.

In 99% of cases, folks use one module per project.  In these cases, the JavaRebel Eclipse IDE plugin can generate the rebel.xml file for you, on a per project basis. If your project is one of the exceptions, edit the file manually as described in the Installation manual, otherwise generate the rebel.xml like this:

Click on your project and pick Generate rebel.xml

2009-07-03_125934

Done.

Repeat this for all projects that you’d like to update with JavaRebel.

If you’d like to use one rebel.xml for your whole team, start with the generated rebel.xml, then replace the absolute paths to your workspace with a system property.  JavaRebel will expand expressions like “${myProject.root}” in rebel.xml to a system property that you can pass to the application container as -DmyProject.root=c:/myWorkspace/myProject. This allows to you to use a single configuration for everyone and then customize it when starting the server.

STEP 4: Configuring IBM Rational Application Developer

You may skip this step if you use the Eclipse IDE or run IBM WebSphere outside the RAD IDE.

Open the Servers View and double click the WebSphere Application Server that your application is deployed to (if you don’t see the Servers View go to Window » Show View » Servers).

2009-07-03_131413

Open Publishing and choose Never publish automatically.

2009-07-03_131724

Open Publishing settings for WebSphere Application Server and choose Run server with resources on server.

It may seem wrong to disable automatic publishing, but as JavaRebel will take care of updates from now on it would just slow you down.

STEP 5: Configuring Eclipse/RAD IDE

Go to Window » Preferences and from there to Java » Debug » Step Filtering. Check Use Step Filters and Filter synthetic methods and Step through filters. Now check all the default filters and use the Add Filter button to add com.zeroturnaround.* and org.zeroturnaround.*.

2009-07-03_143321

Now go to Project » Build Automatically and make sure it is checked.

2009-07-03_144612

STEP 6: Configuring IBM WebSphere

Start the IBM WebSphere server and run the Administrative Console.

2009-07-03_132313

In the Administration Console open Servers » Application Servers and select the server your app is deployed to.

2009-07-03_132842

Select Java and Process Management » Process Definition.

2009-07-03_133200

Select Java Virtual Machine.

2009-07-03_133350

Insert the following line into Generic JVM arguments:

-noverify -Xshareclasses:none -Xbootclasspath/p:%REBEL_HOME%\javarebel-bootstrap.jar;%REBEL_HOME%\javarebel.jar

NB! Unfortunately WebSphere will not expand the environment variable so you have to substitute %REBEL_HOME% with the actual path!

2009-07-03_133601

Press OK, when asked, Save the master configuration and restart the server.

STEP 7:  Success!

To check that the installation was successful access a page that uses a class, change that class in the IDE, press Save, access the page again and look for the following message in the console:

2009-07-03_142228

Find out more:

Join the Rebellion Facebook Twitter RSS feed