How to install and use JavaRebel in GlassFish with Eclipse IDE
How to install and use JavaRebel in GlassFish with Eclipse IDE
In a recently conducted survey the GlassFish v2 application container was the best of the fully fledged Java EE containers in the terms of time spent redeploying. That’s the good news. The not so good news is that on average respondents report spending 19% of their coding time waiting for server redeploys/restarts. That’s just over 150 hours annually, per developer – almost 4 full weeks of development time. JavaRebel eliminates the need to redeploy in about 80% of redeploy situations – and it’s easy to get started. This tutorial explains how to install and use it step-by-step.
Here we assume that you are using Eclipse 3.x with GlassFish v2. Most of the steps will be applicable to other versions as well, but it may look different from the screenshots included.
NOTE: Although GlassFish is tightly integrated with the NetBeans, the JavaRebel support for that IDE is in Beta at the moment – for now, we recommend using Eclipse or IntelliJ IDEA instead. We’ll update this article when better NetBeans support is available.
Contents:
- STEP 1: Install JavaRebel
- STEP 2: Installing JavaRebel Eclipse IDE plugin
- STEP 3: Make a rebel.xml for your application
- STEP 4: Configuring the Eclipse WTP IDE
- STEP 5: Configuring Eclipse IDE
- STEP 6: Configuring GlassFish
- STEP 7: Success!
STEP 1: Install JavaRebel
The latest stable version of JavaRebel can be downloaded here. Unpack it to a directory of your choice.

STEP 2: Installing JavaRebel Eclipse IDE plugin <here>
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.

STEP 3: Make a rebel.xml for your application
The rebel.xml configuration file controls how JavaRebel propagates updates to your application. Specially, it allows you to have a WAR/EAR application deployed as one file to pick up updates made to the project files in the workspace. However for that to work you’ll need to have one rebel.xml file per module. This includes both web and EJB modules. The rebel.xml configuration file should end up in WEB-INF/classes directory in case of a web module and in the jar root in case of an ejb module. This can usually be achieved by placing it in the root of a source folder or a resource folder (same place where the .properties files are).
The JavaRebel Eclipse IDE plugin can generate the rebel.xml file for you. However since it generates it per project, you have to be careful if you have more than one module corresponding to that project and if necessary edit the file manually as described in the Installation manual.
To generate the rebel.xml right click on your project and pick Generate rebel.xml.

Repeat this for all projects that you’d like to update with JavaRebel.
The generated rebel.xml will use absolute paths to your workspace, so you might want to edit it manually and replace the absolute path with a system property as described in the Tips and Tricks section of the Installation manual. If you use Maven you may prefer to 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.
STEP 4: Configuring the Eclipse WTP IDE
You may skip this step if you run GlassFish outside of the Eclipse IDE.
Open the Servers View and double click the GlassFish v2 that your application is deployed to (if you don’t see the Servers View go to Window » Show View » Servers).

Open Publishing and choose Never publish automatically.

It may seem wrong to disable automatic publishing, but as JavaRebel will take care of updates from now on it will just slow you down.
STEP 5: Configuring Eclipse 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.*.

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

STEP 6: Configuring GlassFish
Start the GlassFish server and open the Admin Console.

In the Administration Console open Application Server » JVM Settings » JVM Options

Use the Add JVM Option button to insert the following two new options:
- -noverify
- -javaagent:%REBEL_HOME%\javarebel.jar
NB! Unfortunately GlassFish will not expand the environment variable (even if you define it) so you have to substitute %REBEL_HOME% with the actual path!

Press Save 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:

Find out more:


