Download

Get Loom

Using JavaRebel

JavaRebel is a java agent that reloads changes in Java classes on-the-fly, without redeployments or server restarts. The version currently supported is JavaRebel 1.2 and greater.

Changes to action classes or to any class that contains validated attributes are detected and applied immediately. To test it:

  • Create a project using the scaffolding tool.
  • Download JavaRebel, unzip it and create an environment variable REBEL_HOME, e.g. REBEL_HOME=/usr/local/java/javarebel-2.0.
  • Add "-noverify -javaagent:$REBEL_HOME/javarebel.jar" to your JVM args. If you are using a project created using scaffolding, you should already have two "rebel tomcat" and "rebel jetty" eclipse launch configurations

Next time you start the server JavaRebel should display something like this at the beginning of your log:

##########################################################
# ZeroTurnaround JavaRebel 2.0                           #
# ...                                                    #
##########################################################

Any modification to Action or JPA classes will be detected and applied on the next browser request.

JavaRebel: Reloading class 'org.loom.demo.model.Mortgage'.
13:51:37,014 INFO  [ReloadableActionMappingRepository] Reloading action: org.loom.demo.action.ebanking.MortgagesAction
13:51:37,015 DEBUG [ActionMapping$$M$38b15290] Available events for org.loom.demo.action.ebanking.MortgagesAction are [ save, preEdit, delete, listAll ]
13:51:37,015 DEBUG [AnnotationProcessorRepository] Start processing annotations for org.loom.demo.action.ebanking.MortgagesAction

Notice that modifications to existing Actions will be detected, but new Action classes will not.

Jetty

Jetty has a ClassLoader model that breaks when trying to use JavaRebel. To put together Loom, JavaRebel and Jetty you will need to do one of the following:

  • Do not put javarebel-sdk.jar inside WEB-INF/lib.
  • If you put javarebel-sdk.jar inside WEB-INF/lib, you must add a WEB-INF/jetty-web.xml like this:
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="parentLoaderPriority" type="boolean">true</Set>
</Configure>