Liferay 6.0 Development on Ubuntu Maverick 10.10

Liferay 6.0 Development on Ubuntu Maverick 10.10 #

This article describes what is needed to set up a development environment for Liferay Portal. This article will also show how to upgrade an older environment to Liferay 6.0 GA3 to show how to update the development environment when new Liferay versions are released.

/home/{username}/opt and /home/{username}/workspace will be the paths used for eclipse and its workspace

Many of the dependencies for Liferay development reside in the Ubuntu software repository. Eclipse also exists in the repository but is out of date.

Dependencies for Liferay Development #

The following tools are needed to develop for Liferay:

  • Apache Ant
  • OpenJDK 6.0
  • Eclipse for Java EE
  • Subversion
  • Liferay IDE

Install Ant, Subversion and OpenJDK on Ubuntu by doing the following from a command prompt:

sudo apt-get update
sudo apt-get install ant openjdk-6-jdk libnb-svnclientadapter-java
  • Download Eclipse from here: http://www.eclipse.org/downloads/
  • Choose the Eclipse IDE for Java EE Developers option.
  • Extract Eclipse to /home/{username}/opt
  • Launch Eclipse and set the workspace to /home/{username}/workspace

Subclipse #

Configure Eclipse to find JavaHL for Subversion by modifying /home/{username}/opt/eclipse/eclipse.ini as follows:

-vmargs
-Djava.library.path=/usr/lib/jni

Install Subclipse by doing the following:

Expand Subclipse and select the following components:

  • Subclipse
  • Subversion Client Adapter (Required)
  • Subversion JavaHL Native Library Adapter (Required)

Restart Eclipse

Check Subversion JavaHL by going to Window > Preferences > Team > SVN.

Make sure JavaHL (JNI) appears in the SVN interface section.

Define the Liferay Subversion repository in Eclipse by doing the following:

  • Switch to the SVN Repository Exploring in Eclipse
  • Right-click in SVN repositories pane and click New > Repository Location
  • Enter the following in the Url box:
    svn://svn.liferay.com/repos/public
  • Enter Guest as the username.

Extract Liferay components #

The Liferay components are made up of 3 different components:

  • Liferay Tomcat Bundle
  • Liferay Portal Source
  • Liferay Plugins SDK

Download Liferay from here: http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.0.5/

  • liferay-portal-tomcat-6.0.5.zip
  • liferay-portal-src-6.0.5.zip
  • liferay-plugins-sdk-6.0.5.zip

Liferay Tomcat Bundle #

The Liferay Tomcat Bundle is a fully functional Liferay Portal server pre-configured on Tomcat 6.0.

  • Create a directory called bundles in the Eclipse workspace: /home/{username}/workspace/bundles
  • Extract the Liferay Tomcat Bundle in the newly created bundles directory in the Eclipse workspace

Liferay Portal Source #

The Liferay Portal Source is the source code for Liferay itself. The Liferay Source code serves as a guide to Liferay customisations for Hook Plugins or Extension Plugins.

  • Extract the Liferay Portal Source to /home/{username}/workspace

Liferay Plugins SDK #

The Plugins SDK is used by the Liferay IDE in the background. The reason for this is because the Plugins SDK is IDE agnostic and Plugins developed with the Liferay IDE can still be modified using other IDEs.

  • Create a directory called liferay-plugins-sdk in /home/{username}/workspace
  • Extract Liferay Plugins SDK to the newly created liferay-plugins-sdk directory.

Configure Eclipse for Liferay Development #

Liferay IDE #

Install Liferay IDE by doing the following:

  • Install Liferay IDE in Eclipse by going to Help > Install New Software
  • Paste the following URL in the Work with box and click Add: http://releases.liferay.com/tools/ide/eclipse/helios/stable/
  • Name the site: Liferay IDE

Select Liferay Tooling

Restart Eclipse

Define Liferay Server in Eclipse #

Switch to the Liferay Perspective in Eclipse

Create a new Liferay Server in eclipse by doing the following:

  • Click the Server tab
  • Right-click in the Servers Pane and choose New > Server
  • Select Liferay, Inc. > Liferay v6.0 Server (Tomcat 6)
  • Enter the following for the Liferay Tomcat directory: /home/{username}/workspace/bundles/liferay-portal-6.0.5/tomcat-6.0.26

Configure Liferay Plugins SDK #

Configure the Liferay Plugins SDK by doing the following:

  • Choose Window > Preferences > Liferay > Installed SDKs
  • Click Add
  • Enter the following for Location: /home/{username}/workspace/liferay-plugins-sdk

Import Portal Source Code #

Import the Liferay Portal Source code into Eclipse by doing the following:

  • Right-click in Package Explorer and choose Import
  • Go to General and choose Existing Projects into Workspace
  • Enter the following for the root directory: /home/{username}/workspace/liferay-portal-src-6.0.5
  • liferay-portal-src-6.0.5 should show up in the Project list
  • Click Finish

Creating a Test Plugin #

This section will create a test plugin to make sure that the development environment is properly configured.

  • In the Liferay Perspective click File > New > Liferay Plug-in Project
  • Name the project Test and click Finish
  • Click File > New > Liferay Portlet
  • Make sure the Test-portlet project is selected
  • Choose javax.portlet.GenericPortlet as the Superclass and click Finish
  • Drag and drop the Test-portlet project onto the Liferay Portal server in the servers pane.
  • Start the Liferay Portal Server
  • Once the Server is started, Right-click the Server and choose Liferay > Open Portal Home
  • Log in to Liferay using the username/password test@liferay.com/test
  • Click Add > More > Sample
  • Drag NewPortlet onto the Welcome Page

Debugging in Eclipse #

Set a break point in the Test-Portlet #

  • In the Test-Portlet project go to docroot/WEB-INF/src > com.test and open NewPortlet.java
  • Set breakpoint on the following line: include(viewJSP, renderRequest, renderResponse);

Start the Liferay Server in Debug mode #

  • Double-click the Liferay Server
  • Click Open launch configuration
  • Click the Source Tab and add the Java Project Test-portlet
  • Save the server configuration.
  • Right-click the Liferay Server and choose Restart in Debug.

After Liferay has started, a Debug session should start at the break point that you have set in the Test-Portlet project.

Upgrading Liferay components to 6.0 GA3 (6.0.5)#

Use the following steps to upgrade an older version of Liferay Portal GA3 (6.0.5):

  • Stop the Liferay Server if its running
  • Extract the Liferay Tomcat Bundle in /home/{username}/workspace/bundles
  • Extract the Liferay Portal Source to /home/{username}/workspace
  • Extract Liferay Plugins SDK to /home/{username}/workspace/liferay-plugins-sdk overwriting the previous version.

This does not have any impact any custom projects in the Plugins SDK.

Reconfigure the Liferay Server in Eclipse by doing the following:

  • Launch Eclipse
  • Go to Window > Preferences > Server > Runtime Environments
  • Highlight Liferay v6.0 (Tomcat 6) and click Edit
  • Change the Liferay Tomcat directory line to: /home/{username}/workspace/bundles/liferay-portal-6.0.5/tomcat-6.0.26

Fix a classpath issue with the Liferay Server by doing the following:

  • Go back to the Liferay Perspective
  • Double-click the Liferay Server
  • Click Open launch configuration
  • Click the Classpath Tab and remove the bootstrap.jar that points to the old bundle
  • Save the server configuration.

Import Portal Source Code #

Import the Liferay Portal Source code into Eclipse by doing the following:

  • Delete the previous liferay-portal-src code project from eclipse
  • Right-click in Package Explorer and choose Import
  • Go to General and choose Existing Projects into Workspace
  • Enter the following for the root directory: /home/{username}/workspace/liferay-portal-src-6.0.5
  • liferay-portal-src-6.0.5 should show up in the Project list
  • Click Finish

Test-portlet will have to be re-added to the Liferay Server before it will show up in the new Portal.

Liferay Plugin Source Code Management #

Checking Liferay projects into and out of a Source Code Management system is a little different because of the Liferay Plugins SDK. Liferay projects are quietly being added to the Liferay Plugins SDK in the background which leads to interesting issues when checking out of Subversion or CVS. A project must be re-associated with the Plugins SDK on checkout. Failure to do so will cause the project to quit working properly in Eclipse.

Details on the subject can be found here Liferay IDE Sharing Projects

0 Attachments
24092 Views
Average (4 Votes)
The average rating is 5.0 stars out of 5.
Comments
Threaded Replies Author Date
Nice article. I hope it should be ok not only... Alexey Kakunin October 4, 2010 2:10 PM
It should work fine with Ubuntu 10.04. What... Jamie L Sammons October 4, 2010 4:34 PM
I went ahead and changed the installation... Jamie L Sammons October 4, 2010 4:48 PM
hi, Nice article and one question: can i use... Bradai Salma March 10, 2011 6:40 AM
Hi, when I try to install the Liferay IDE,... Thomas Menke July 5, 2011 10:56 AM
ah sry... I guess I am just using the wrong... Thomas Menke July 5, 2011 2:23 PM
Hi good article Just wanted to point out some... Jakob Fahrner July 19, 2011 7:28 AM

Nice article.
I hope it should be ok not only for ubuntu 10.10, but for ubuntu 10.04,
Also, I think it is not necessary to describeinstalling of liferay 6.0.4 and upgrade to 6.0.5 - pretty sure it is possible directly install liferay 6.0.5 emoticon
Posted on 10/4/10 2:10 PM.
It should work fine with Ubuntu 10.04.

What I was trying to do with installing 6.0.4 first was to show how one would go about patching the development environment when newer versions of Liferay ship. The upgrade steps should work equally well when Liferay 6.1 ships.
Posted on 10/4/10 4:34 PM in reply to Alexey Kakunin.
I went ahead and changed the installation section to make it based on 6.0.5. I left the upgrade section as a reference for upgrading from older versions of Liferay.

Thanks for the feedback!
Posted on 10/4/10 4:48 PM in reply to Alexey Kakunin.
hi,
Nice article and one question:
can i use the source code in liferay-portal-src and change it in order to change some existing portlet?
Posted on 3/10/11 6:40 AM in reply to Alexey Kakunin.
Hi,

when I try to install the Liferay IDE, eclipse is angry with me because of an unmet dependency:

Cannot complete the install because one or more required items could not be found.
Software being installed: Liferay IDE 1.2.3.v201103310212 (com.liferay.ide.eclipse.tools.feature.group 1.2.3.v201103310212)
Missing requirement: Liferay Plugin SDK 1.2.3.v201103310212 (com.liferay.ide.eclipse.sdk 1.2.3.v201103310212) requires 'bundle org.eclipse.ant.launching 0.0.0' but it could not be found
Cannot satisfy dependency:
From: Liferay Project Core 1.5.0.v201103310212 (com.liferay.ide.eclipse.project.core 1.5.0.v201103310212)
To: bundle com.liferay.ide.eclipse.sdk 0.0.0

Well... I downloaded the SDK and extracted the file into workspace, but I never told eclipse about it. So perhaps there is a step missing?
Posted on 7/5/11 10:56 AM in reply to Bradai Salma.
ah sry... I guess I am just using the wrong version of eclipse... I need to update...
Posted on 7/5/11 2:23 PM in reply to Thomas Menke.
Hi
good article
Just wanted to point out some problems I run into:
First I had some permission problems installing subclipse (because I installed eclipse to /opt and not /home/{username}/opt)
Second Eclipse didn't asked me for a svn username or password until I changed the svn Url from "svn://svn.liferay.com/repos/public" to "http://svn.liferay.com/repos/public"

One question similar "Bradai Salma" ones is there a possibility to load the standard portlets as plugins into eclipse (would be nice to have best-practice examples to look at)
Posted on 7/19/11 7:28 AM.