Welcome to my Liferay Portal Portlet Install Tips. I will grow this page organically and try to cover examples of how to install the Portlets which come with the Liferay Portal plus any external ones I think are interesting.

I'll cover the hurdles that I ran into with respect to installing the Portlets. One might be inclined to think that it should be as simple as just dropping the WAR file into the Webapps directory and it will automatically be picked up. It's not quite that simple but almost that simple. It's also easy to tie yourself up in knots with respect to the dependencies the various Portlets have.

Introduction

A standard portlet contains a portlet.xml file. In the case of Liferay, they extend this config metaphor to have a second file called liferay-portlet.xml contained in WEB-INF directory. The reason for this is that the Liferay Portal has additional config in relation to the standard Portlet config. Therefore, if you are adding your Portlet to Liferay, these files need to be updated. The good news is that Liferay is extremely well structured and there is an environment called the ext-environment which facilitates and automates this need.

Getting your ext environment in place

To install this piece, go to the Liferay site and follow the Documentation link. There you'll find instructions on how to setup the ext environment. Esstentially what you need to do is go to the SourceForge location where the source code is resident and download a pre-packed set of source code for your version. In the current case it's Liferay 4.2.1 but that will change over time. Bundled with each set of source files are sample .WAR files which represent the portlets you can choose to install. Liferay itself comes bundled with quite a few pre-canned Portlets so you might not need these. However, if you plan to create your own unique application style environment, these give you a great handle on the way to get going. Note: I came a little unstuck when I first tried to compile the source. Make sure you're using JDK 1.5 or later. JDK 1.4 gave me 'Out of Memory' errors when I tried. You'll also need to configure an portlet-ext.proprties in the ext environment which matches the one you setup for the Liferay WAR file. It might seem like a lot of hassle to get this setup but it's well worth it and will slowly take a lot of the mystery out of the Portal codebase.

Overview of the Liferay Portlets

On my Liferay instance, I have installed most of the sample Portlets but each one has proved difficult! Having come from the Tomcat world, when I saw a WAR file, I thought all I needed to do was drop the WAR file into the container and it would work straightaway. This is Open Source. It does work but it means you have to put on your thinking cap. No hand holding here! First tip when installing the WAR files.

Running examples of the Portlets

  • Deploy the WAR files from your ext enviroment which you'll have setup
  • The path I use is liferay/portal/ext/portlet
  • I do 'ant deploy' and the WAR file in this directory is registered and deployed
  • Read the Liferay Portlet guide for more detailed info
  • EXPECT the Portlet not to work when you deploy it! OR when you run it
  • You WILL be missing JARs which you must figure out
  • Or there may be a small tweak you need to make to the WAR to get it running
  • Liferay Forums will help here but don't always expect a reponse
  • Do not (as I did) dump all your unresolved WAR JAR dependencies into the Tomcat servlet lib directory to get one WAR running. You will probably break the other WAR's because you'll be mising Spring JAR versions without realizing it.
  • Instead, drop your WAR JAR dependencies into the respective WAR/WEB-INF/lib directory

Here's what I had to do for the Spring example to work. If you're interested in this, here is the link. To get it up and running required me adding additional WAR files to the Liferay WEB-INF/lib directory.

http://www.blokefood.com/liferay-portal-4.2.1 /web/blokefood/spring_example

To common/lib/ext, I added xercesImpl.jar log4j.jar and to the sample-spring-portal/WEB=INF/lib, I added commons-fileupload.jar jstl.jar util-taglib.jar util-java.jar

Hopefully, this may save you some time if you're trying to get this up and running.

From the link, you can also see links to the JSF Demo, DAO Demo and the Tapestry Demo etc;