Imagine a bacon-wrapped Ferrari. Still not better than our free technical reports.
See all our reports

JRebel How-to: Changing Liferay JSP hooks without redeploying

Liferay users will be happy to know that it is possible to make a Hook so that you can reload JSP changes without redeploying your application. For those of you new to Liferay and/or JRebel, hooks are small programs that you deploy to overwrite some small part of Liferay’s default functionality. By using Liferay JSP hooks, you can keep your code separated from the default Liferay code; and since Liferay is open source, you can download it, make your code changes then deploy it. By adding JRebel to this equation, you can enjoy a super-fast feedback cycle by eliminating the redeployment process altogether. This is a small “JRebel with Liferay” screencast designed to show you how to do just that. The following versions of software were used in this demo:
  1. Eclipse-jee-indigo-SR1-win32-x86_64
  2. Liferay IDE 1.4.0 (From eclipse marketplace)
  3. JRebel 4.5.3 (201112070111) (From eclipse marketplace)
  4. Liferay CE 6.0.6 SDK and bundled tomcat-6.0.29
Before we begin, we should make the following assumptions:
  • You have your development environment ready.
  • You have Eclipse installed and it has plugins for both JRebel (or JRebel for Eclipse) as well as Liferay IDE.
  • You have made a Liferay server runnable in Eclipse and have set up a Liferay SDK project.
In this tutorial we will be:
  1. Starting Liferay server with JRebel enabled.
  2. Making a small JSP hook, adding and modifying rebel.xml.
  3. Deploying the hook on server.
  4. Seeing that when we change the JSP, the page is changed on refresh.
Source code of the hook: JRebelTest-hook

Questions and Answers:

Q: I made a change to a JSP in my hook but the entire hook is immediately redeployed on save. Is JRebel supposed to do that? A: When a change is made to JSP, only the changed file must be reloaded. The probable cause is that when you change your hook Eclipse automatically publishes the hook to Liferay. It can be disabled under server “Overview” (Eclipse Servers tab -> double click on a Liferay server): Liferay disable publish   Q: I have JRebel Eclipse plugin installed, but there are no JRebel check boxes in my IDE, what might be wrong? A: Currently we have the JRebel check boxes in Liferay 6 CE versions IDE, but not in Liferay EE-s Liferay Developer Studio (they will be in JRebel nightly version build soon) If you don’t have JRebel check boxes you can add JRebel arguments under server console:   unsing Liferay with JRebel We hope this post about Liferay JSP hooks was useful, and please leave your feedback below in the comments section!

  • Bijan Vakili

    It’s quite useful article. A picture speaks a thousand words. Thanks.

  • Qsd Qsd

    And what about portlets ? Does it works ?

  • The best is to try it yourself ;)
    AFAIK, there we no problems with JRebel and portlets in Liferay and that works fine. The JSP hooks is a Liferay-specific feature so it was a joint effort to create this integration http://www.liferay.com/web/jan.gregor/blog/-/blogs/11416402