Liferay with GlassFish

Install Liferay with GlassFish Bundle#

System Requirements#

  • Memory: 1GB RAM Disk Space: 500MB
  • System Architecture: X86/SPARC
  • Operating System: Solaris/Linux/MacOS X/Windows/AIX
  • JDK 1.6.x/1.5.x (Only 1.5.x on Mac)
  • Apache Ant

Install Steps#

  1. Download Liferay bundled with Glassfish for your platform from
  2. java -Xmx256m -jar liferay-portal-glassfish-(platform)-(version).jar -console
  3. cd glassfish
  4. ant -f setup.xml
  5. ./bin/asadmin start-domain

Wait for 1min for glassfish and liferay to initialize.

Access Portal at http://localhost:8080/portal The first request will take a while to respond since JSPs are compiled.

Troubleshooting missing ant#

If step 4 complains about ant not existing you may use the bundled version. Replace step 4 with:

 4.1. chmod -R +x lib/ant/bin/ant
 4.2. lib/ant/bin/ant -f setup.xml

Troubleshooting log4j dependency#

When using Liferay 4.4.2 and possibly others. (This is not a problem with Liferay 5.1.1) If the above instructions don't work (after waiting a minute or so), check domains/domain1/logs/server.log for an entry similar to

 [#|*|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|*|WebModule[]PWC1270: Exception starting filter Secure MainServlet Filter
 **java.lang.NoClassDefFoundError: //org/apache/log4j/Logger**//'//****//

A Simple workaround is:

  1. Download log4j.jar (version 1.2) to glassfish/domains/domain1/lib
  2. Restart the glassfish domain
    1. [Base-Dir]/glassfish/bin/asadmin stop-domain
    2. [Base-Dir]/glassfish/bin/asadmin start-domain

Use MySQL as the portal database #

  1. Make sure Glassfish is running
  2. Open http://localhost:4848/ in your browser, and log in as username : admin, password : adminadmin
  3. In the menu in the left, choose "Common Tasks->Resources->JDBC->Connection Pools->LiferayPool"
    1. Change "Datasource Classname:" from "org.hsqldb.jdbc.jdbcDataSource" to "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource".
    2. Change "Resource Type:" from "javax.sql.DataSource" to "javax.sql.ConnectionPoolDataSource"
    3. Click "Save"
    4. Go to the "Additional Properties" tab in the same screen, and change username from "sa" to "lportal", and password from "" to "lportal"
    5. Delete property "database".
    6. Add properties "databaseName" with value "lportal", "serverName" with value "localhost", and "port" with value "3306"
    7. Click "Save"
    8. Possibly also add the following properties useUnicode=true, characterEncoding=UTF-8, useFastDateParsing=false
  4. Stop the GlassFish server, and then start it again. (I am not sure if this is needed, or if there is some way to have GlassFish only restart the Liferay web applications.)
    1. bin/asadmin stop-domain
    2. bin/asadmin start-domain
  5. Open http://localhost:8080/ in your browser, and you should see Liferay running off MySQL portal database

Known Issues #

  • On Mac port of JDK 1.6 does not work

Please use JDK 1.5.x on Mac.

I was able to run setup using SoyLatte by editing setup.xml. SoyLatte returns Darwin as the OS Name, so if you change <os name="Mac OS X"/> for <os name="Darwin"/>, the setup works. After the succesful setup with SoyLatte, the portal seems to run just fine. So, for now, if you want to use JDK 1.6, SoyLatte is the option.

  • Accessing http://localhost:8080/portal does not bring up Liferay portal.

First Access takes some time. Maybe a minute to respond. This is because the process is busy compiling the JSPs, loading the database schema and data. This may be a memory issue, especially if you are using JDK 1.5. Try accessing the URL again - it took me a couple of tries for it to work.

  • /Users/user1/.asadmintruststore (Permission denied) when running ant -f setup.xml fails.

I believe NetBeans 6 installed this file as root and I was installing as a non-root user. I used the sudo command to install as root to workaround this problem

  • Mac - library issue (5.1.1)

java.lang.NoSuchMethodError: org.apache.xml.utils.DefaultErrorHandler.<init>(Z)V at org.apache.xalan.processor.TransformerFactoryImpl.<init>(

Copy the following JAR files

  • serializer.jar
  • xalan.jar
  • xml-apis.jar
  • xercesImpl.jar

from glassfish/domains/domain1/applications/j2ee-modules/liferay-portal/WEB-INF/lib/ to glassfish/domains/domain1/lib/

Thanks to Virgilio, from the forums

Install Liferay Manually on Glassfish V2#


  1. Create a directory into which to store and extract the download files (e.g. C:\Liferay).
  2. Go to
  3. Download the Liferay Portal 4.X.Y WAR file for Servlet 2.4 to the directory (e.g. C:\Liferay).
  4. Download the Liferay Portal 4.X.Y Dependencies file and unzip to the dependencies subdirectory (e.g. C:\Liferay\dependencies).
  5. Download the Liferay Portal 4.X.Y SQL Scripts file and unzip to the sql subdirectory (e.g. C:\Liferay\sql).
  6. Download the Liferay Plugins SDK 4.X.Y file and unzip to the sdk subdirectory (e.g. C:\Liferay\sdk).
  7. Download the Liferay Portal 4.X.Y Web Services Client and unzip to the ws-client subdirectory (e.g. C:\Liferay\ws-client).
  8. Download the Liferay Portal 4.X.Y JavaDocs and unzip to the doc subdirectory (e.g. C:\Liferay\doc).

Database configuration:

  1. Login as the administrator to the database of your choice.
  2. Select either the minimal installation (scripts in the sql/create-minimal subdirectory) or the full example installation (scripts in the sql/create subdirectory) and run the script for your database server (e.g. create-mysql.sql). The default database created by the script is called lportal.
  3. Recommended security: Create a separate Liferay database user and grant it SELECT, INSERT, UPDATE, and DELETE permissions on all tables in the lportal database.

Glassfish configuration:

  1. Stop Glassfish if it is running.
  2. Copy the Liferay dependencies to the Glassfish domains/<liferay_domain>/lib subdirectory.
  3. Copy the xercesImpl.jar file from the Liferay sdk/lib subdirectory to the Glassfish domains/<liferay_domain>/lib subdirectory.
  4. Copy any required bridges (e.g. jsf-portlet.jar) to the Glassfish domains/<liferay_domain>/lib subdirectory.
  5. Copy the JDBC driver for your database to the domains/<liferay_domain>/lib directory.
  6. Start Glassfish and login to the Admin Console.
  7. Go to Resources/JDBC/Connection Pools and create a connection pool to connect to the lportal database.
  8. Go to Resources/JDBC/JDBC Resources, create a JDBC resource with the name jdbc/LiferayPool, and associate it with the connection pool created in the previous step.
  9. Go to Resources/JavaMail Sessions and create a JavaMail resource with the name mail/MailSession.
  10. Deploy the Liferay WAR file to the server with the context root /.
    1. If the application server is running locally, set the upload option to false (if using the asadmin command-line tool) or use the Local packaged file or directory that is accessible from the Application Server option in the Admin Console.
    2. For faster application load times, precompile the JSPs (this will take several minutes).
    3. Do not run the verifier, as the sun-web.xml file does not match its DTD and will cause a deployment failure.

Liferay configuration:

  1. Go to the Liferay portal (http://localhost:8080/ if running locally under Glassfish).
  2. Sign in as the administrator (
  3. Add the “Plugin Installer” portlet if not present.
  4. Go to the “Configuration” tab of the “Plugin Installer”.
    1. Change the “Deploy Directory” to the deployment directory of your choice.
    2. Press “Save”.
0 Attachments
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Threaded Replies Author Date
You may encounter out-of-memory errors when... Scott Fordin December 19, 2008 1:56 PM
I found a useful guide for installing Liferay... sdfsd sdfds November 11, 2009 12:39 PM
This solution has been tested and verified to... sdfsd sdfds November 11, 2009 12:40 PM
I believe the URL you're trying to link to is... Liferay Mailinator November 16, 2009 2:42 PM
Hi I've put together some instructions on... Garry Donnelly April 17, 2010 7:39 PM
Hi All I want to know how to install/deploy ... DarshanKumar N Bhatia April 27, 2010 2:14 AM
Really very helpful document Shrinivas Zilli December 3, 2010 11:07 AM

You may encounter out-of-memory errors when launching the GlassFish JAR-based installer. To avoid these errors, set larger initial and maximum memory heap sizes with the -Xms and -Xmx options on the java command line. For example:

java -Xms512m -Xmx1024 -jar <glassfish_jar>.jar
Posted on 12/19/08 1:56 PM.
I found a useful guide for installing Liferay as a service on GlassFish v3 Prelude here:
Posted on 11/11/09 12:39 PM.
This solution has been tested and verified to work with Liferay Portal 5.2.3
Posted on 11/11/09 12:40 PM in reply to sdfsd sdfds.
I believe the URL you're trying to link to is here:
Posted on 11/16/09 2:42 PM in reply to sdfsd sdfds.

I've put together some instructions on installing the latest version of Liferay on Glassfish with MySql. All seems to be running well so I posted the details on my blog here:­-glassfish-applicaiton-server-over-ssh

Posted on 4/17/10 7:39 PM.
Hi All

I want to know how to install/deploy liferay with Sun Java Application server .
Posted on 4/27/10 2:14 AM.
Really very helpful document
Posted on 12/3/10 11:07 AM.