Today I tried to build a simple Hello World portlet with Liferay Portal. I am a little disappointed that the documentation isn’t as straight forward as I expected. I had to read through several documents and was confused by outdated/conflicting information. So, I am sharing my setup notes for people who might be interested to give it a try.
- Download Liferay binary here. I downloaded the Tomcat bundle for ease of configuration. YMMV with other bundles.
- Follow the quick installation here. I didn’t have any issue starting Tomcat with Liferay. It brings up the default portal page automatically. Do not close this page. We will revisit this page in a later step.
- Download SDK from here. Look for a download link that starts with “Liferay Plugins SDK”.
- If you don’t have Ant setup in your environment, follow the instructions in page 6 of the development documentation here. My environment is already setup with ant, so I just skipped this step.
- Customize your own
build.${username}.properties. I made copy of${sdk_directory}/build.propertiesand created my own file in the same directory using thebuild.${username}.propertiesconvention documented in page 7 of the development guide. Within this file, I updatedapp.server.dirproperty with the path to Tomcat’s directory in my local environment. The document has a typo about the other property:java.compiler. Reading thebuild.propertyfile suggested to me that the property name should bejavac.compiler. Since I only wanted the default configuration, which ismodern, I didn’t change this second property. - Create a portlet using ant: I followed the instruction on page 8 in the development guide. It is very straight forward. Make sure you run the create command in the portlets directory in the sdk directory.
cd ${sdk_directory}/portlets ant -Dportlet.name=hello -Dportlet.display.name="hello world title" create - After created the portlet, you should see a new directory that looks like
hello-portlet. You can go into that directory and make changes to your liking. Since my goal was just to get a simple portlet running, I just added “Hello World” tohello-portlet/docroot/view.jspfile. - Deploy the portlet: Within the
hello-portlet, I ran the following command to deploy the portlet:ant deploy
- After I deployed the portlet, I did a quick check in the log file (
catelina.out) to see if the portlet is available. I did notice that the message is slightly different from what development guide stated. - Add the portlet to the portal page: I returned to the default portal page on my browser. On the default portal page, there is a menu that has the label “welcome” on the to right corner. Liferay documentation called this “Dock”. If you mouse over this, you will see login option. To login, enter “bruno@7cogs.com” for email address and “bruno” for password. This information comes from the quick installation guide. All other documentation that I read all refers to “test@liferay.com” and “test”, which are wrong for the release that I downloaded. Once log-in, You can mouse over to the Dock and choose “Add Application”. Enter the name of your portlet in the search textfield, the list should automatically updated. If you can identify your portlet, click the “Add” link next to it. You should see the portlet showing on the portal page.
That should get your development setup for further portlet development. Have fun coding!
Update: If you want to use Glassfish, see Ari’s blog on this topic.

ziggy said
Thanks i will try this out as soon as i get home. I have to say that the liferay documentation is really unhelpfull. Most of the documentation is for version 4 of liferay so it just confuses everything.
Lakshman Mukkamalla said
Thanks dave. The steps that you have provided were good enough and saved lot of time instead of reading all the initial steps from the dev docs of liferay.
satish said
HI This is satish.ch
i have developed a portlet in plugin sdk as per upper details.but still i am not getting a new folder in portals in plugin sdk.
i kept ant 1.7,ligferay tomcat5.5 and plugin sdk in d:drive of my computer.
can u help me please?
kalolo said
Great post, really helpfull, thanks
Krishna Mohan said
satish said,
Add create word to the ant command, it should work. Like..
cd ${sdk_directory}/portlets
ant -Dportlet.name=hello -Dportlet.display.name=”hello world title” create
Bala said
Krishna,
it throughs error message when i use abouve command “Build Fail”. Please let me know any other option.
Thanks,
Bala.
j1nxx said
Thanks for this great post, helped me alot!
Blogimise motiivid « Borich's Blog said
[...] Spetsialistide blogid. Kui mingil eriteadlasel on unikaalne kogemus mingil alal ja ta tahab seda jagada teistega, ta kirjutab sellest omas ajaveebis. Antud juhul motiiviks on puhas altruism. http://vegdave.wordpress.com/2009/04/01/building-a-helloworld-portlet-with-liferay/ [...]
Venu said
Good Tutorial. I tried your steps and got it worked.
Thanks for your tutorial.
PJ said
dave,
Amazing Job!!! Thank you for such simple and easy to follow instructions.
I’ve distilled your steps into a sequence of command-line commands, if anyone is interested. This installs liferay into /user/local, and sets up the sdk in a liferay directory in the user’s home folder.
$ mkdir -p ~/liferay/software
$ cd ~/liferay/software
$ wget http://sourceforge.net/projects/lportal/files/Liferay%20Portal/liferay-portal-tomcat-6.0-5.2.3.zip
$ wget http://downloads.sourceforge.net/lportal/liferay-plugins-sdk-5.2.3.zip
$ sudo unzip liferay-portal-tomcat-6.0-5.2.3.zip -d /usr/local/
$ unzip liferay-plugins-sdk-5.2.3.zip -d ~/liferay
# Note that the following uses the backtick ` character (below the tilde ~ on your keyboard).
$ sudo adduser `whoami` users # Add yourself to the “users” group
$ sudo chown -R root:users /usr/local/liferay-portal-5.2.3
$ sudo chmod -R g=u /usr/local/liferay-portal-5.2.3
# Open a new terminal window and type:
$ cd /usr/local/liferay-portal-5.2.3/tomcat-6.0.18/bin; ./catalina.sh run
# In the original terminal window…
$ cd ~/liferay
$ cp build.properties build.`whoami`.properties
$ sed -i ’s|app.server.dir=${project.dir}/../bundles/tomcat-6.0.18|app.server.dir=/usr/local/liferay-portal-5.2.3/tomcat-6.0.18|g’ ~/liferay/build.`whoami`.properties
$ cd ~/liferay/portlets
$ sudo apt-get install ant
$ ant -Dportlet.name=hello -Dportlet.display.name=”hello world title” create
$ cd ~/liferay/portlets/hello-portlet
$ ant deploy
# In your Web Browser…
# In the Current Users portlet, click on “Login as bruno” link.
# Hover over “Welcome Bruno admin” at the top right.
# Click “Add Application”
# In the “Add Application” portlet, expand “Sample”
# Ckick “Add” next to “hello world title”
Dave said
Thanks PJ for sharing your tips!
Shane Chambers said
Yes, the Liferay documentation that I ran across was terrible. Seems they keep changing where things are located and so this invalidates any existing documentation. I found it very confusing. In LR’s documentation they are talking about the creation of EXT folders and there is no mention of such folders here. Would be nice if this article would put the version of liferay they are using for the future.
Dan Cripe said
Thanks! Very helpful and saved me a ton of time!
CymnOrierie said
Full Movie Review:
or replacing Kurt Russell , Download Movie online Download Movie Review: or Sigourney Weaver as Ripley. But Tony Podesta, . for the film have only been given Download Movie online DVD Download Movie for the film have only been given . Online movie Review pre-dating Craig’s grittier , Actors Clooney, Pitt and Denzel . who takes office Movie online their character’s name. . Online movie DVD movie during the campaign. , and news organizations. DVD DivX iPod movie . http://99minutes.net/download/star-wars-episode-i-the-phantom-menace/trackback/ , In fact the only example secretive about . DVD Hi-Def DivX quality Download Movie online DivX Download Movie Movie online . Download Full-lenght DVD Hi-Def DivX quality was not well accepted, Full Hi-Def iPod quality .