Friday, 2 October 2009

Struts and EJB application to JSR 168 Portlet

This has been quite a journey for me to convert an existing Struts2 application to a JSR 168 compliant Portlet which now runs using IBM WebSphere Server and Liferay Portal. The application also uses EJB and Hibernate.

Here are the steps that can probably help you in converting a Struts application to a Portlet.

Environment used by me : IBM RAD 7, Websphere, Liferay 5.2.3, Oracle 10g

Environment that you can use : Any IDE preferbly Eclipse/JBoss/IBM RAD, Portal Server of your choice like Liferay/JBOSS/Apache/IBM Portal, Oracle/Mysql/SQL Server Database

Tools used by me : Apache Struts Portal Bridge: Details at

Getting Started:

1. For this article we will employ Apache Portal Bridge. The reason I have used it is because if you dont use this then you will have to make changes to your action classes and jsp's as per JSR 168/286 specification.

2. First step will be to get Liferay up and running on your application server. For me it was IBM Websphere 6.1
I basically used Liferay Portal 5.2.3(without dependencies) and then downloaded the dependencies separately. You can follow the admin guide for setting up Liferay on any server.
The important point to keep in mind is : file to specify Database configuration and hibernate dialect settings. Place this in /web-inf/classes

3. Setup the database by executing the create-minimal script.

4. Install the Liferay war in your application server. Check logs for any possible errors.

5. Start Liferay and check for http://localhost:9080.

6. Once you are done with this then next step will be to convert your application to JSR Portlet.

Start by downloading the Apache Struts Portal Bridge from Apache.

If you are working with IBM Websphere 6.1 the you need to take care of two things:

a. IBM has its own Portal Server which acts as the default server. You need to stop that so that Liferay can pick your application. To do this follow the following links:

Exploiting the WebSphere Application Server V6.1 portlet container

PK34915: allow web applications to disable portlet deployment

To disable portlet deployment this APAR, PK34915 is required and the portlet application must set the context parameter
"" to "false" within the web.xml.

For doing this you will need IBM Update Installer. If you dont have one follow this "" target="_blank">link

b. In you need to define a websphere-deploy folder where Liferay places the war that is placed in the deploy folder. It is this war that you need to install in IBM Websphere.

Here is a sample from my properties file:

changes in file : which is most important


You also need to specify a websphere-deploy folder where Liferay will place your war

After this you need to copy all the dependency libraries to the lib folder in web-inf.

If your Web Application uses EJB then you need to setup EJB as a separate jar in Websphere or JBoss. Next access them remotely from your web application.

Check the portlet.xml file, it should have a the Portlet name defined.

You dont need anything in web.xml except for EJB references.

Final Checklist would be:

1. The web.xml doesn't need any entries at all for Struts 2.1.6 version.
2. Both the ServletContextHolderListener and the Preparator servlet have been depracated. So you don't need them anymore.
3. The FilterDispatcher filter appears to be optional.
4. The DispatcherServlet only need to be included in the deployment descriptor if JSTL tags are needed by your application.
5. Configure the liferay specific descriptors (liferay-portlet.xml, liferay-display.xml) as usual.
6. In the file, You must include the following Liferay portal jar dependencies: freemarker.jar,
7. In your portlet /lib folder, include these required Struts 2 jar files: struts2-core-2.1.6.jar, struts2-portlet-plugin-2.1.6.jar, xwork-2.1.2.jar, ognl-2.6.11.jar
8. Your struts.xml descriptor should be located in the classes folder.

Export your Web Application as WAR and install it to your server along with any EJB jars.

You should be all set then.

In my next Post I will cover some important links/references and also what changes you will need in the jsp files.


  1. Thanks for the information,

    Can you please sent me the sturts based portlet sample which you had converted into JSR 168/286 on liferay/jboss

    my email Id :

    Surender Kajla

  2. Please visit the following Link :