JRebel maps your project workspace directly to a running application, watches for the changes you make to classes and resources, and intelligently reflects them in your application. In order for it to do that, JRebel needs to know where your classes and resources are. We use the rebel.xml configuration file to map your deployed project back to your workspace. This is mandatory when you deploy your app as a WAR/EAR. You'll need to have one rebel.xml file per each module. This includes both web and EJB modules.

The rebel.xml configuration file should end up 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 or a jar library. Put it in the root of a source or resource folder in your project (the same place where the .properties files are) and make sure it's copied to the target directory.

Configuring JARs

JARs are usually not deployed on their own, but as a part of application (e.g. WEB-INF/lib in WARs or EJB modules in EARs). However, often you still want to update their code on-the-fly. Let's assume that we have a module my-business-module.jar deployed in WEB-INF/lib. You can propagate the changes from your workspace by adding the following rebel.xml to the root of the JAR file:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath> <dir name="c:\myWorkspace\myBusinessModule\target\classes"/>
<dir name="c:\myWorkspace\myBusinessModule\src\main\resources"/>
</classpath> </application>

This will mount classes and resources in directories c:\myWorkspace\myBusinessModule\target\classes and c:\myWorkspace\myBusinessModule\src\main\resources before the classes and resources in the JAR file. Changes to those classes and resources will propagate to the application.

Configuring WARs

In case of a web application you have web application resources, like JSPs, HTML files, graphic files and so on in addition to the classpath. To configure a web application deployed as a WAR file we create a rebel.xml file in the WEB-INF/classes directory:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath> <dir name="c:\myWorkspace\myWar\target\classes"/>
<dir name="c:\myWorkspace\myWar\src\main\resources"/>
</classpath> <web> <link target="/">
<dir name="c:\myWorkspace\myWar\src\main\webapp"/>
</link> <link target="/jsps/">
<dir name="c:\myWorkspace\myWar\src\main\jsps"/>
</link> </web> </application>

This will mount classes and resources in directories c:\myWorkspace\myWar\target\classes and c:\myWorkspace\myWar\src\main\resources to the application classpath before the deployed classes and resources. This means that those classes and resources will override the ones in WEB-INF/classes and WEB-INF/lib/*.jar. Changes to those classes and resources will propagate to the application.

This will also map the web resources in the c:\myWorkspace\myWar\src\main\webapp directory to the root ("/") of the web application context and the web resources in c:\myWorkspace\myWar\src\main\jsps directory under the /jsps/ URI of the web application context. You may map several directories to one context target if necessary.

Configuring EARs

To configure a EAR you need to create a separate rebel.xml file for each EAR module. Web modules should be configured same as individually deployed WARs, EJB modules should be configured same as JARs. If your container supports APP-INF/classes you may also add a rebel.xml to that folder and mount classes and resources that belong to the EAR as a whole.

Using Relative Paths

Putting absolute paths in the rebel.xml might be a bad idea as you'd like to share it with other team members. Luckily JRebel will expand expressions like "${myproject.root}" in rebel.xml to a property that you provide. You can set this property as a Java System property (-Dmyproject.root=c:/projects/) or in the JRebel Agent Configuration:


Tips and Tricks