Note

Configuring the rebel.xml configuration file is considered an advanced procedure. We highly recommend getting in touch with support via support@zeroturnaround.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.


<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).

  • 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).
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>
    ...
  </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>

<dirset>

Defines multiple subdirectories of a directory that can be added to classpath. Nested include/exclude tags can be used to limit the subdirectories included from the specified directory.

Attribute Description Required
dir The parent directory from which subdirectories are found. By default all will be added. 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>
    <!--
      DIRSET enables you to add multiple directories to the classpath
      without specifying them one-by-one. For example if there are multiple
      MAVEN modules with a similar folder structure. The following configuration
      will include all modules from the directory of "C:\projects\project1Root\
      that adhere to the pattern "**\build\classes".
    -->
    <dirset dir="C:\projects\project1Root\">
      <include name="**\build\classes"/>
    </dirset>
  </classpath>

</application>

<jar>

Defines a JAR file that is added to classpath or link. Nested include/exclude tags can be used to limit the resources included from the specified JAR.

Attribute Description Required
name Full path to a JAR file that is added to the classpath. 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>
    <!--
      Adds a JAR file to the classpath. The classes from the
      JAR archive can also be excluded or included based on patterns.
    -->
    <jar name="C:\projects\myProject\3rdpartyLibs\myLibrary.jar">
      <!-- Including everything from com/yourapp/package1-->
      <include name="com/yourapp/package1/**"/>
      <!-- Exclude the unimportant subpackage of package1-->
      <exclude name="com/yourapp/package1/unimportant/**"/>
    </jar>
  </classpath>

</application>

<jarset>

Defines multiple JAR files to be added to classpath. Nested include/exclude tags can be used to limit the JARS included from the specified directory.

Attribute Description Required
dir JAR files from this directory on the filesystem are added to the classpath. 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>
    <!--
      JARSET enables you to add multiple JAR files to the classpath without
      specifying them one-by-one. The following example includes JAR files
      from the app/3rd-party-lib directory that don't match the pattern apache*.jar.
    -->
    <jarset dir="app/3rd-party-lib">
      <exclude name="apache*.jar"/>
    </jarset>
  </classpath>

</application>

<war>

Overrides the WAR file deployed to the container with a exploded directory or a WAR file on the filesystem. Needs to have either dir or file attribute.

Attribute Description Required
dir Path to an exploded WAR directory on the filesystem. Resources and class files will be loaded from this directory. Yes/No
file Path to a WAR archive on the filesystem. Resources and class files will be loaded from this file. Yes/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://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">
  <!--
    WAR tag with FILE attribute specifies the location of the WAR file.
    The contents of this WAR file will have higher priority as compared
    to the web application deployed. All resources in this file will be
    available in the web application just as they would be in the
    deployed WAR file.
  -->
  <war file="C:\projects\myProject\dist\myProject.war" />
</application>
<?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">
  <!--
    WAR tag with DIR attribute specifies the location of the exploded
    directory. The contents of this directory will have higher priority
    as compared to the web application deployed to the container. All
    resources in this folder will be available in the web application
    just as they would be in the deployed web application.
  -->
  <war dir="C:\projects\myProject\dist\war" />
</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>

</application>