Develop with JRebel
Building your web application and redeploying it every time you want to see the effects of the changes you made to your project's source code can be a time consuming process. If you want to speed up this development cycle, then JRebel is a great tool to make that happen. Although it is a commercial product, if you are a member of a qualified open source project, you can request a free JRebel license. For Eclipse users an alternative to using JRebel is documented here.
You can get a free 14 day trial of JRebel here. After downloading and unpacking JRebel you must set the REBEL_HOME environment variable to point to the JRebel root directory. For instance:
Generating the JRebel descriptors
The Hippo Project POM provides a profile dedicated to generating and enabling JRebel while building and running a Hippo project. This profile is activated by specifying the property jrebel. To generate the JRebel descriptors, simply build your project using the following command:
mvn verify -Djrebel
JRebel descriptors for both CMS and site are generated, which means that class files and resources from either project are configured to be monitored for changes. Open cms/target/classes/rebel.xml and site/target/classes/rebel.xml to see how JRebel is configured.
Note: When you are ready to create a project distribution be sure you have a clean build without the JRebel profile activated. Otherwise rebel.xml files will be packaged with the wars of your distribution. The JRebel profile can be explicitly de-activated by running the Maven command with -P !jrebel.
Running with JRebel
The same profile also takes care of enabling the JRebel java agent when running Cargo. To run Cargo with JRebel enabled, use the following command to run your project:
mvn -P cargo.run -Djrebel
Instead of using a standalone installation of JRebel you can use the JRebel Plugin for the IDEA of your choice. That way you can work with JRebel without having to use a command line tool.
Debugging in Eclipse while running JRebel at the same time
If you are an Eclipse user and want to debug your project while running JRebel at the same time, then you should consider installing the JRebel Eclipse Plugin. If you use JRebel in debug mode without it, then after you add some changes to your code, the debugger will get confused because it doesn't expect the new methods to appear. Thus you will not be able to set a breakpoint on that code and the stepping behaviour is impaired when you hit code the debugger is not yet familiar with. With the JRebel Eclipse plugin, this situation is remedied.
Disable JRebel CXF plugin
For some reason, after you have recompiled something and JRebel picks it up, the HST REST services do not work anymore. This can be fixed by disabling the 'CXF' JRebel plugin:
- Install the JRebel plugin for your IDE
- Open the 'Plugins' section of the JRebel plugin configuration
- Disable the 'CXF Plugin'
You can also disable other plugins you do not need.
If there's no JRebel plugin for your IDE, you can also edit the JRebel configuration manually. It is stored in the file
In this file, add the following line:
Reload JAXRS endpoint resources and (JAXB) representations without restart
Annotations of JAXRS Resource Beans and (JAXB) representations do not get refreshed when they are changed and compiled, even with JRebel enabled. This is because CXF only loads the annotations once. A restart of the application (no rebuild needed because JRebel did replace the classes) is then needed.
However, there is a nicer workaround: Namely, when the HST-2 container gets reloaded, the CXF controller is reloaded as well. You can trigger the HST-2 container to be reloaded when you touch (add a space and save) the hst-config.properties. After the reload, all changes in your JAXRS resources and (JAXB) representations will be picked up.
To make sure that the HST-2 container is reloaded after a change in the hst-config.properties you need to have in your site web.xml HstConfigServlet also the init param hst-config-refresh-delay configured, for example:
<servlet> <servlet-name>HstSiteConfigServlet</servlet-name> <servlet-class>org.hippoecm.hst.site.container.HstSiteConfigServlet </servlet-class> <!-- If 'hst-config-refresh-delay' parameter is greater than 0, then the HST configuration file changes will be monitored to re-initialize the HST Container. The value is in ms. If set to 0 or missing, the re-initialization option on configuration file changes is not turned on. Default below is set to 3 sec --> <init-param> <param-name>hst-config-refresh-delay</param-name> <param-value>3000</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>