Pedro Marques
Pedro Marques

Reputation: 327

Liferay Portlets Deployment

Good afternoon.

I'm working on a migration from WebSphere to Liferay 6.2 CE.

So far I am able to Export the main project to a WAR file, and Import it in Liferay.

The real problem comes on a development environment...

When changes are made to the project, the deployment process is time consuming. It is necessary to exclude the previous portlet, and install the new one with the changes compiled.

Is there an easier way to deploy the project, directly has a Liferay Portlet? Something like, click a button or run a command, and have it deployed immediately to Liferay's Server.

Best regards.

Upvotes: 1

Views: 757

Answers (1)

Chris Maggiulli
Chris Maggiulli

Reputation: 3824

Build and Deployment Automation

Liferay 6.2 portlet development supports Ant, Ivy, and Maven build automation. Our developers typically use the Ant build scripts that come standard with Liferay 6.2, and we use Jenkins to automate our deployments to our various test and production servers.

However, even with the aforementioned tools, builds in 6.2 can be tedious and very time consuming. This issue is mostly eliminated in DXP with the introduction of OSGi modules but these OSGi modules are not supported in 6.2.

While Liferay does not provide a solution for this out-of-the-box there is one tool above all else that has drastically decreased our build and deployment times in 6.2

JRebel

JRebel is a fabulous product for Java EE development and has been especially helpful and supported on the Liferay platform. Essentially JRebel is a tool that allows you to save changes to your code and see those changes instantly without running any Ant targets or moving any war files around.

JRebel is not a free product (it costs $500 a year per license) but you can get a free copy (with 100% of the functionality) if you are using for non-commercial projects. To get a license simply search for "My JRebel" and register an account.

JRebel for Liferay

JRebel integrates very easily with Liferay, and there is some documentation on the Liferay Blogs regarding configuration. However the last time I checked the blog posts outline an older way of configuration that is no longer supported (or at least no preferred). Therefore I will briefly go over the steps needed to configure JRebel with Liferay.

Configuration

Follow these steps after you have obtained either a free license through My JRebel or purchased a license key if this is a commercial project. If you are onboarding this tool at your company you will definitely want to use their license server.

  1. Open your Liferay Development Studio (or Eclipse IDE with the Liferay plugin installed) and go to Help > Eclipse marketplace.
  2. Once the Eclipse Marketplace window loads search for JRebel and go through the download and installation process.
  3. Once the installation process is complete (and your IDE has restarted), go to Help > JRebel > Activation.
  4. You will have a window with three options (activation code, license key, license server). If you are using My JRebel you will likely have a .lic file. You will want to select that option and locate the file on your system. If you are using this in an enterprise setting I highly suggest using a license server. If have not included directions for that as it is outlined elsewhere and is not at all specific to Liferay.
  5. Once JRebel is activated you should now see a JRebel configuration perspective in the top right hand corner

enter image description here

  1. Click on the perspective, navigate to the start up tab, and select the following configurations

enter image description here

  1. Then navigate to the projects tabs and select all the portlets you want to apply JRebel to. Only select the first box unless you are running some type of container environment (which you did not specify).

enter image description here

  1. Then in your Eclipse menu select Project > Build Automatically

Testing your configuration

There are a few indications that your configuration is working. Firstly, in your projects source folder you should see a rebel.xml configuration file.


enter image description here


If you see the file there it's time to start the server. Immediately after starting the server you will some new lines written at the top of the catalina log file.


enter image description here


Additionally in your Tomcat's temp folder you should see a new JRebel directory.


enter image description here


Once the portal loads make a change to one of your Java files. In the Catalina console you should see a newly printed line with the fully qualified name of the class you just modified. Check to see if your change has taken effect!

Issues

If you have issues at any part in this process there are a few things you might want to look out for. If you are receiving any permgen errors you might want to modify the JVM flags related to memory in your server configuration panel. Additionally in the same location you may need to toggle the publish automatically settings. Additionally I have always had issues with JRebel not working for made to method signatures in the ORM files generated by service builder. If I am adding a new method to those classes JRebel doesn't pick it up. If I am adding or modifying the type of a parameter in one of the methods in those classes JRebel doesn't pick it up. Changes to the code in the localserviceimpl and serviceimpls seems fine in all other regards, and every other class works fine with JRebel. The engineers at ZeroTurnAround swear it works perfectly with Service Builder, but I haven't had success in those aforementioned cases.

Upvotes: 1

Related Questions