Note

Configuring the rebel.xml configuration file is considered an advanced procedure. We highly recommend getting in touch with support via support-rebel@perforce.com when you believe manually editing rebel.xml is required.

rebel.xml reference

The configuration file rebel.xml needs to be used for web applications that use packaged deployment (for example WARs, JARs and EARs). Instead of the WAR/JAR/EAR file, all resources will be picked up from the locations provided in rebel.xml. These directories and archives will be monitored for changes.

The rebel.xml configuration file must be placed in the WEB-INF/classes directory of the deployed WAR file, in a root directory of a JAR file or in the root of EJB JAR modules. A rebel.xml file should be provided for each separate module in the application that you want to change.

Note

The contents of rebel.xml are defined by the schema available at http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd.

A complete example has been provided at the end of this file.

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 using a single configuration for everyone and customizing it when starting the server.

Automatically expanded path variables are available when running your server from the IDE, if you are using Eclipse or IntelliJ IDEA. Refer here for instructions.

Tip

  • You are not limited to mounting directories to classpath. You can also mount JARs with <jar>.

  • JARs or folders added to the Java modulepath are added to the classpath of the runtime application, and if it includes a rebel.xml then the modulepath can be used to search for the rebel.xml file.

  • If you need to mount a lot of directories or JARs at once you can use <dirset> or <jarset> that accepts Ant-style patterns to specify the specific directories.

  • You can use Ant FileSet-style include and exclude directives in the <dir> and <jar> entries.


<application>

This is the top level tag that defines the configuration with classpath, WEB and WAR tags.

<?xml version="1.0" encoding="ISO-8859-1"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
  ...
</application>

<classpath>

Defines the mounted classpath of the application with nested dir, dirset, jar and jarset elements. The fallback attribute checks whether classes and resources are also found from the original application classpath (for example WEB-INF/classes, WEB-INF/lib/\*.jar, JAR root and so on).

Attribute

Description

Required

fallback

Values: all, none and default (default).

No

all – classes and resources will always be found from both the original and mounted classpath. This mode may cause some resources to appear double in the application.

none – classes and resources will only be found from the mounted classpath. This mode requires all classes and resources (including those in WEB-INF/lib/\*.jar) to be fully mounted.

default – classes and resources will be found from both original and mounted classpath, but resources present in both will be filtered out. This mode implies that classes and resources in the path that contains rebel.xml are fully present in the mounted classpath (all classes and resources in WEB-INF/classes should be mounted when rebel.xml is present).

<?xml version="1.0" encoding="ISO-8859-1"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <classpath>
    ...
  </classpath>

</application>

<dir>

Directory on the filesystem that is added to classpath or link. Nested include/exclude tags can be used to limit the files included from the specified directory.

Attribute

Description

Required

name

The full path to a directory in the filesystem.

Yes

include

Specifies a pattern that directs which resources will be included from the parent.

No

exclude

Specifies a pattern that directs which resources will be excluded from the parent.

No

<?xml version="1.0" encoding="ISO-8859-1"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <classpath>
     <!--
      Add a directory with class files to the classpath. The classes
      can also be excluded or included based on patterns.
     -->
     <dir name="C:\projects\myProject\classes\">
       <!-- Including everything from com/yourapp/package1-->
       <include name="com/yourapp/package1/**"/>
       <!-- Exclude the unimportant subpackage of package1-->
       <exclude name="com/yourapp/package1/unimportant/**"/>
     </dir>
  </classpath>

</application>

<web>

Defines separate locations for static resources that can be referenced from the web application. With nested link tags it is possible to map different resources from the filesystem to the web context.

<?xml version="1.0" encoding="ISO-8859-1"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com"
             xsi:schemaLocation="http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <!--
    WEB tag defines separate locations for static resources that can be referenced from
    the web application. Directories containing jsp, css, html, gif etc. files. These
    directories can be mapped to arbitrary locations for the web application.
  -->
  <web>
    ...
  </web>

</application>

<include>

This element is used to filter resources in dir, dirset, jar and jarset elements. Resources named by this element will be included in the result. This element uses Ant-style patterns.

Attribute

Description

Required

name

Name that will be filtered. Can contain wildcards. See example for more information.

Yes

<dirset dir="C:\projects\project1Root\">
  <include name="**\build\classes"/>
</dirset>
...
<jarset dir="app/3rd-party-lib">
  <exclude name="apache*.jar"/>
</jarset>
...
<jar name="C:\projects\myProject\3rdpartyLibs\myLibrary.jar">
  <!-- Include all of package1-->
  <include name="com/yourapp/package1/**"/>
  <!-- Except for internal subpackage-->
  <exclude name="com/yourapp/package1/internal/**"/>
</jar>

<exclude>

This element is used to filter resources in dir, dirset, jar and jarset elements. Resources named by this element will be excluded from the result. This element uses Ant-style patterns.

Attribute

Description

Required

name

Name that will be filtered. Can contain wildcards. See example from include tag for more information.

Yes

<dirset dir="C:\projects\project1Root\">
  <include name="**\build\classes"/>
</dirset>
...
<jarset dir="app/3rd-party-lib">
  <exclude name="apache*.jar"/>
</jarset>
...
<jar name="C:\projects\myProject\3rdpartyLibs\myLibrary.jar">
  <!-- Include all of package1-->
  <include name="com/yourapp/package1/**"/>
  <!-- Except for internal subpackage-->
  <exclude name="com/yourapp/package1/internal/**"/>
</jar>

Sample configuration

The following file can be copied to your project. The relevant sections can be deleted or customized.

<?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://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

  <classpath>
    <dir name="C:/Users/user/workspace/spring-petclinic/target/classes">
    </dir>
  </classpath>

  <web>
     <link target="/">
        <dir name="C:/Users/user/workspace/spring-petclinic/src/main/webapp"/>
     </link>
  </web>

</application>