This article covers a Bloomreach Experience Manager version 13. There's an updated version available that covers our most recent release.

Develop with JRebel

This documentation describes the use of a third-party development tool and is maintained by Bloomreach on a best-effort basis. Bloomreach cannot guarantee this documentation is up to date with the latest release of the third-party development tool. Please refer to the documentation of the third-party development tool for the latest installation, configuration, and usage instructions.

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.

Installing JRebel

You can get a trial of JRebel here. After downloading and unpacking, configure the JRebel Agent according to the settings found in the JRebel documentation.

To use the JRebel Agent when running the project locally with Cargo, set the javaagent property in your ~/.m2/settings.xml Maven configuration settings or project. For instance:

<profile>
  <id>jrebel</id>
  <activation>
    <property>
      <name>jrebel</name>
    </property>
  </activation>
  <properties>
    <javaagent>-agentpath:/home/user/jrebel/lib/libjrebel64.dylib</javaagent>
  </properties>
</profile>

Generating the JRebel descriptors

The Bloomreach Experience Manager Project POM provides a profile dedicated to generating and enabling JRebel while building and running a Bloomreach Experience Manager project. This profile is activated by specifying the property jrebel. To generate the JRebel descriptors, 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

To run Cargo with JRebel enabled using the profile defined above, use the following command to run your project:

mvn -P cargo.run -Djrebel

The javagent property can also be set directly from the command line without changing the project or settings.xml. For instance:

mvn -Pcargo.run -Djavaagent=-agentpath:/home/user/jrebel/lib/libjrebel64.dylib

IDE plugin

Instead of using a standalone installation of JRebel you can use the JRebel Plugin for the IDE 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:

  1. Install the JRebel plugin for your IDE
  2. Open the 'Plugins' section of the JRebel plugin configuration
  3. 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

~/.jrebel/jrebel.properties

In this file, add the following line:

rebel.cxf_plugin=false

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>

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?