Starting with JRebel 2.0 rebel.xml
file must be used
for web applications that use packaged deployment (i.e. WARs, JARs and
EARs). Instead of the WAR/JAR/EAR file deployed all resources will be
picked up from the locations provided in the rebel.xml
.
Also these directories and archives will be monitored for changes.
The rebel.xml
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 per
each module in the application that you want to change on-the-fly.
The contents of the
rebel.xml
is defined by the schema at
http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd
. There is a full example 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
to use a single configuration for everyone and then customize it when starting the server.
<?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://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
...
</application>
Defines the mounted classpath of the application with nested dir, dirset, jar and jarset elements. The fallback attribute controls if classes and resources are also found from the original application classpath (e.g. WEB-INF/classes, WEB-INF/lib/*.jar, JAR root, etc).
Attribute | Description | Required |
fallback | Values: all ,
none and default
(default).
|
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://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<classpath>
...
</classpath>
</application>
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 | A full path to a directory on the
filesystem. |
Yes |
includes | Specifies a pattern that directs which resources will be included from the parent. | No |
excludes | 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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
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 |
includes | Specifies a pattern that directs which resources will be included from the parent. | No |
excludes | 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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
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 |
includes | Specifies a pattern that directs which resources will be included from the parent. | No |
excludes | 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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
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 |
includes | Specifies a pattern that directs which resources will be included from the parent. | No |
excludes | 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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
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://www.zeroturnaround.com/alderaan/rebel-2_0.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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
Can be added to web to link a nested dir or jar to the target URI. The mapped resource is made available from servlet context and also via HTTP.
Attribute | Description | Required |
target | Mapping target. For example "gfx/" or "js/". | Yes |
<?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://www.zeroturnaround.com/alderaan/rebel-2_0.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>
<!--
The location c:\projects\myProject\static\gfx will be accessible to the WEB
application as http://yourhost/webapp/gfx folder. Adding static resources to
that location will let you use them from your web application.
-->
<link target="gfx/">
<dir name="c:\projects\myProject\static\gfx"/>
</link>
</web>
</classpath>
</application>
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\">
<exclude 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>
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 |
The following file can be copied to your project and appropriate sections deleted or customized.
<?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://www.zeroturnaround.com/alderaan/rebel-2_0.xsd">
<!--
Classpath allows you to add DIRECTORIES and JAR files to your classpath. Your
webapp will see these resources as resources inside the WAR archive or your
exploded directory.
The default value of fallback is true. When set to 'false' then if a resources
is NOT found from the defined directories, it won't be looked for from the
deployed resources.
Example. Fallback is set to FALSE and you remove a styles.css file. Even though
a styles.css file is deployed to the container, it will give a 404 on HTTP request
or null on ServletContext lookup even though it exists in the deployed archive.
If set to true, all resources will fallback to the deployed application, this is
the default behavior.
-->
<classpath fallback="default">
<!--
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\">
<!-- Only include package1 and its subpackages -->
<include name="com/yourapp/package1/**"/>
<!-- Except com/yourapp/package1/package2 and its subpackages -->
<exclude name="com/yourapp/package1/package2/**"/>
</dir>
<!--
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">
<!-- Only include package1 and its subpackages -->
<include name="com/yourapp/package1/**"/>
<!-- Except com/yourapp/package1/package2 and its subpackages -->
<exclude name="com/yourapp/package1/package2/**"/>
</jar>
<!--
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 c:\projects\3rd-party-lib directory that don't match the pattern apache*.jar.
-->
<jarset dir="c:\projects\3rd-party-lib">
<exclude name="apache*.jar"/>
</jarset>
<!--
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\">
<exclude name="**\build\classes"/>
</dirset>
</classpath>
<!--
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" />
<!--
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"/>
<!--
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>
<!--
The location c:\projects\myProject\static\gfx will be accessible to the WEB
application as http://yourhost/webapp/gfx folder. Adding static resources to
that location will let you use them from your web application.
-->
<link target="gfx/">
<dir name="c:\projects\myProject\static\gfx"/>
</link>
<!--
The location c:\projects\jsProject\dist\js will be accessible to the WEB
application as http://yourhost/webapp/js folder. Adding static resources to
that location will let you use them from your web application.
-->
<link target="js/">
<dir name="c:\projects\jsProject\dist\js"/>
</link>
</web>
</application>