← Back to team overview

dhis2-devs team mailing list archive

Using jrebel to stop waiting for redeploying

 

Hi all,

One of the most time consuming task when programming with dhis2 is waiting
for redeploying. When a small change on java code  must take few minutes
for jvm to reload the context, coding becomes very arduous task, especially
building portal with a large number of modules.

I have tried JRebel and it is a big surprise to me. Going beyond what the
company (ZeroTurnaround) advertises, JRebel is really rocks: Java code
change effects immediately, so do *.vm, js, css; super easy to getting
start (please see my tutorial below); and its completely free if you join
their social license, a license that integrates with Facebook so that
JRebel can post few message on your behalf claiming how much time you can
save using JRebel. Don't worry this posting is so rare, once  a week or
month.

Steps to start DHIS2 with JRebel.

1. Follow the following tutorial to register the license (it is just a
hashed string, you copy and paste into your license activation step)
http://zeroturnaround.com/software/jrebel/jrebel-social-tutorial/

2. Now steps to configure JRebel with dhis2. I know most of dhis2
developers use Maven instead of IDE to build. Documents on how to run
JRebel with Maven is a bit scarce however there is a few. This is a good
one.
*
http://padcom13.blogspot.com/2011/09/using-jrebel-from-pure-maven-in-web.html
*
*
*
*Remember:
3. In the pom.xml, you need to set the maven jrebel plugin, i.e.*
   <!-- enable generation of jrebel.xml - needed for the agent -->
      <plugin>
        <groupId>org.zeroturnaround</groupId>
        <artifactId>jrebel-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-rebel-xml</id>
            <phase>process-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

4. In the environmental variables, set MAVEN_OPTS to have javaagent which
points to the folder of jrebel.
My MAVEN_OPTS as I extracted jrebel in C:/
[image: Inline image 1]
5. Then use mvn jetty:run and enjoy autoredeploy of JRebel. Now all the
changes on classes and webapp will be watched and redeployed. Therefore, in
your IDE you must set on Build Automatically so that every change on source
will be compiled to classes.

Note that dont use *maven jetty:**run-war* as Jrebel will watch changes on
target/classes and it is not what we want.
*
*
It might require several rounds of configuration until JRebel get run but
the result is so rewarded. Let me know if you have any issues.

Thanh

PNG image


Follow ups