Building a Hello World portlet with Liferay

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.

  1. Download Liferay binary here. I downloaded the Tomcat bundle for ease of configuration. YMMV with other bundles.
  2. 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.
  3. Download SDK from here. Look for a download link that starts with “Liferay Plugins SDK”.
  4. 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.
  5. Customize your own build.${username}.properties. I made copy of ${sdk_directory}/ and created my own file in the same directory using the build.${username}.properties convention documented in page 7 of the development guide. Within this file, I updated app.server.dir property with the path to Tomcat’s directory in my local environment. The document has a typo about the other property: java.compiler. Reading the file suggested to me that the property name should be javac.compiler. Since I only wanted the default configuration, which is modern, I didn’t change this second property.
  6. 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"hello world title" create
  7. 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” to hello-portlet/docroot/view.jsp file.
  8. Deploy the portlet: Within the hello-portlet, I ran the following command to deploy the portlet:
    ant deploy
  9. 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.
  10. 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 “” for email address and “bruno” for password. This information comes from the quick installation guide. All other documentation that I read all refers to “” 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.


34 thoughts on “Building a Hello World portlet with Liferay

  1. 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.

  2. 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.

  3. HI This is
    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?

    1. Sir ., i am getting error as

      D:\code home\plugin\build-common-plugin.xml:294: D:\code home\bundles\tomcat-6.0.29\webapps\ROOT\WEB-INF\lib not found.

      can u suggest me for same

  4. satish said,

    Add create word to the ant command, it should work. Like..

    cd ${sdk_directory}/portlets
    ant”hello world title” create

    1. Krishna,

      it throughs error message when i use abouve command “Build Fail”. Please let me know any other option.


  5. 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
    $ wget
    $ sudo unzip -d /usr/local/
    $ unzip -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; ./ run

    # In the original terminal window…
    $ cd ~/liferay
    $ cp 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”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”

    1. Thanks a lot for your sharing, it easy to understand than going to the liferay document. it helps me a lot to be familiar with life ray portlet.

    2. Sir ., i am getting error as

      D:\code home\plugin\build-common-plugin.xml:294: D:\code home\bundles\tomcat-6.0.29\webapps\ROOT\WEB-INF\lib not found.

      can u suggest me for same

  6. 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.

  7. 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 . , 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 .

  8. I’ve tried this tutorial and it run perfectly.
    This is exactly what the new Liferay developers need, especially for the version 5.2.x, cos I found it so hard to find a straight-forward guidance like this.

    Thanks lots Dave!

  9. Hi Dave,

    I am getting the following message

    C:\liferay-plugins-sdk-5.2.3\portlets\build.xml:29: C:\bundles\tomcat-6.0.18\webapps\ROOT\WEB-INF\tld not found.

    Can you specify how to set path to appserver,i am using liferay-tomcat6.0.18

    1. hi Mangapathi…
      In u r SDK folder create file and add app.server.dir=Path to u r tomcat folder and then build

  10. Articles are created to express different body of knowledge. That is why I admire writers who are passionate of doing such incredible job. I salute you guys. By the way, I like you post for it is specifically talk about current issues and technicalities in life. I look forward for your subsequent post.I look forward for your next article.Thanks Marks Liferay Development

  11. Greetings I am so grateful I found your weblog, I really found you by error, while I was researching on
    Aol for something else, Anyways I am here now and would just like to
    say kudos for a tremendous post and a all round interesting blog (I also love the theme/design), I don’t have time
    to read it all at the minute but I have saved it and also included your
    RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the
    awesome work.

  12. Hi there! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a marvellous job!Mission Viejo Roofing Service, 26161 Cordillera Drive, Mission Viejo, CA 92691 – (949) 238-6004

  13. I think this is among the most significant information for me.
    And i’m glad reading your article. But should remark on some general things, The website style is wonderful, the articles is really excellent : D. Good job, cheers

  14. Fantastic post but I was wanting to know if you could write
    a litte more on this topic? I’d be very grateful if you could elaborate a little bit further. Cheers!

  15. Excellent post! We will be linking to this particularly great
    content on our site. Keep up the great writing.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s