You are here

Using JRebel on the command line

JRebel can be used with the Alfresco SDK to implement Test Driven Development (TDD).
This tutorial looks at using the Alfresco SDK with JRebel without an IDE.
Important: JRebel-related functionality, while still available, has been deprecated and is no longer supported.
You should first complete the tutorial to create a simple AMP project before attempting this tutorial, as you will need a simple AMP project to work with. If you prefer, you can create a fresh project to work with using the guidelines given in the tutorial. This tutorial will assume you have a simple AMP project created in the directory simple-module-project.
You will see how to install JRebel and then configure the Alfresco SDK to use it in your Test Driven Development. In this tutorial you will see configuration for the command line.
  1. Import your simple AMP project into Eclipse if you have not already done so, using the instructions in the tutorial Alfresco SDK with Eclipse as your guide.

There are two distributions of JRebel can that be installed at this point. You can choose to install a command line version, or a version integrated with your IDE. You will see how to run the command-line version of JRebel in this tutorial.

  1. If you do not already have JRebel installed, visit the official website and download the current stable version of JRebel. You will also need to obtain an activation key from ZeroTurnaround.
  2. Once downloaded, unzip JRebel into a suitable location, and then run bin/ In the dialog displayed, copy your activation key and then complete the registration.
  3. You now need to make an addition to your MAVEN_OPTS environment variable. Modify your MAVEN_OPTS variable to include the following additional option -javaagent:/path/to/jrebel/jrebel.jar.

    Important: You will need to modify this option so that it reflects the actual location on your specific system where the jrebel.jar file is installed to.
  4. Change into the simple-module-project directory and type the following command to build and run your project:

      mvn clean install -Pamp-to-war,rad                  
    Attention: Note the use of the rad profile, which is used for Rapid Application Development.
    Attention: If you have correctly installed JRebel, and configured your MAVEN_OPTS correctly, you will see a number of JRebel monitoring messages in the terminal window.
  5. Once the application has fully started you can display http://localhost:8080/alfresco/service/index. This will provide validation that Alfresco is running.
  6. Load the file src/test/java/org/alfresco/demoamp/test/ into an editor of your choice.
  7. Now you will introduce a deliberate error into the test code, and re-run the test. In the source code, locate the testGetCompanyHome() method.
  8. Locate the following line of code:

        assertEquals("Company Home", companyHomeName);                        
  9. Change the code to the following:

        assertEquals("Company Hotel", companyHomeName);                        

    This will cause the test to fail when it is re-run.

  10. Run the test.

    After a short interval the test will fail.

  11. Change the code back to remove the error. Save your changes.
  12. Re-run the test.

    The test will run very quickly (without any reloading of the application server).

You have seen that the Alfresco SDK integrates painlessly with JRebel. This helps to create a Test Driven Development environment, where code changes and tests can be carried out without the time-consuming necessity for application server restarts.

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.