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).
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 the 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.
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 system property
that you can pass to the application container as -DmyProject.root=c:/myWorkspace/myProject
. This allows
to use a single configuration for everyone and then customize it when starting the server.<jar>
.<dirset>
or <jarset>
that accepts Ant-style patterns to specify the specific directories.<dir>
and <jar>
entries.Read about those options and more in the configuration manual.