Wiki

Clone wiki

lmf / JRebel

Describes how to use JRebel for hot deployment of LMF

Introduction

JRebel is a Java Agent allowing for hot deployment of changed Java classes during runtime. All LMF modules have JRebel support built-in (using the JRebel Maven Plugin). This page describes how to use JRebel during development with Maven.

Install JRebel

To use the LMF with JRebel, it is first necessary to install JRebel from the ZeroTurnaround website.

JRebel is free for Open Source projects, so as long as you are working on the LMF itself you can request an Open Source license from their webpage.

Start LMF Webapp

The LMF is already preconfigured for using JRebel. The JRebel Maven Plugin is used to generate an appropriate rebel.xml file for each LMF module (see parent POM file for the configuration). The rebel.xml file assumes that the root directory where you have your LMF source code is passed as argument (system property rebel.root) when starting.

Assuming you have the LMF source code checked out at /path/to/src/LMF and JRebel installed in /path/to/jrebel, you can start the lmf-webapp using the following command:

mvn clean tomcat7:run -Drebel.root=/path/to/src/LMF -javaagent:/path/to/jrebel/jrebel.jar

Alternatively, you can add the JRebel agent in your MAVEN_OPTS, avoiding to pass it as argument at every running:

export MAVEN_OPTS="$MAVEN_OPTS -javaagent:/path/to/jrebel/jrebel.jar"

The LMF will start up watching all LMF source directories for changes and hot deploy classes when they are updated.

Hot Deployment

Actually hot updates through the classloader. When you change the source code in one of the modules, all you have to do to hot deploy the changes in the running web application is to run

mvn compile

in the module with the changed sources.

This will generate new versions of the classes in {MODULE}/target/classes, which are automatically picked up by JRebel and deployed in the running server.

Take into account that JRebel could not monitor all classes related with persistence (hibernate entities), so in that case you would need to manually re-deploy anyways to reinitialize the database.

Updated