I setup Liferay 5.0.1 on Glassfish v2 to test some JSR-168 Portlets
as part of Project OpenPTK.
Here are my notes on getting Liferay running.
I installed this configuration on my Apple MacBook Pro with Leopard (10.5).
The liferay website does not have an install guide for release 5.0.
I used the 4.4 Admin guide.
This wiki site
has some useful information for installing Liferay with Glassfish. These docs got
me going but I had to perform a few extra / different steps to make things work.
Pre-condition:
Set some variables:
- export GLASSFISH=/usr/local/glassfish_v2
- export LIFERAY=/work/Software/Projects/liferay_v5.0
- export MYSQL=/usr/local/mysql
Create a directory to store and extract the downloaded files: ${LIFERAY}
Download Software:
http://www.liferay.com/web/guest/downloads/additional.
- Liferay Portal 5.0.1 WAR file for Servlet 2.4 to the directory: ${LIFERAY}
- Liferay Portal 5.0.1 Dependencies file and unzip to the dependencies subdirectory: ${LIFERAY}/dependencies
- Liferay Portal 5.0.1 SQL Scripts file and unzip to the sql subdirectory: ${LIFERAY}/sql
- Files for Developers: Liferay Plugins SDK 5.0.1 file and unzip to the lib subdirectory: ${LIFERAY}
MySQL Database configuration:
Login as the administrator to the database of your choice.
Select either the minimal installation (scripts in the sql/create-minimal
subdirectory) or the full example installation script (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.
Recommended security: Create a separate Liferay database user
and grant it SELECT, INSERT, UPDATE, DELETE permissions on all
tables in the lportal database.
# mysql -uroot -ppassword < ${LIFERAY}/liferay-portal-sql-5.0.1/create-minimal/create-minimal-mysql.sql
# mysql -uroot -ppassword
mysql> grant all on lportal.* to lportal identified by 'lportal';
mysql> grant all on lportal.* to lportal@localhost identified by 'lportal';
Create a new Glasfish domain:
| admin name: | lportal |
| admin password: | lportallportal |
# ${GLASSFISH}/bin/asadmin create-domain --adminport 14848 --instanceport 18080 lportal
Please enter the admin user name>
Please enter the admin password>
Please enter the admin password again>
Please enter the master password [Enter to accept the default]:>
Please enter the master password again [Enter to accept the default]:>
Using port 14848 for Admin.
Using port 18080 for HTTP Instance.
Default port 7676 for JMS is in use. Using 50684
Default port 3700 for IIOP is in use. Using 50685
Default port 8181 for HTTP_SSL is in use. Using 50686
Default port 3820 for IIOP_SSL is in use. Using 50687
Default port 3920 for IIOP_MUTUALAUTH is in use. Using 50688
Default port 8686 for JMX_ADMIN is in use. Using 50689
Domain being created with profile:developer, as specified by variable AS_ADMIN_PROFILE in configuration file.
Security Store uses: JKS
Domain liferay created.
Stop Glassfish if it's running:
# ${GLASSFISH}/bin/asadmin stop-domain lportal
Copy some files:
Copy the Liferay dependencies to the Glassfish domains/lportal/lib
subdirectory.
# cd ${LIFERAY}/liferay-portal-dependencies-5.0.1
# cp portal-kernel.jar portal-service.jar portlet.jar ${GLASSFISH}/domains/lportal/lib
Note: the docs for Liferay 4.4 mention copying the xercesImpl.jar file.
Liferay failed to run and gave me errors about missing other classes. After
adding a jar and restarting a few time ... I got it working by adding these other
two jar.
Copy the xercesImpl.jar, xalan.jar and serializer.jar file
from the Liferay lib subdirectory to the
Glassfish domains/lportal/lib subdirectory.
# cp ${LIFERAY}/lib/xercesImpl.jar ${GLASSFISH}/domains/lportal/lib
# cp ${LIFERAY}/lib/xalan.jar ${GLASSFISH}/domains/lportal/lib
# cp ${LIFERAY}/lib/serializer.jar ${GLASSFISH}/domains/lportal/lib
Copy the JDBC driver for your database to the domains/lportal/lib directory.
# cp mysql-jdbc.jar ${GLASSFISH}/domains/lportal/lib
Start Glassfish:
# ${GLASSFISH}/bin/asadmin start-domain lportal
Resources/JDBC/Connection Pools:
If you are using the Glassfish web-based admin console,
go to Resources/JDBC/Connection Pools and create a connection pool to
connect to the lportal database. Here is the asadmin command
to perform the same function.
Usage: ${GLASSFISH}/bin/asadmin create-jdbc-connection-pool
--datasourceclassname classname
[--terse=false]
[--echo=false]
[--interactive=true]
[--host localhost]
[--port 4848|4849]
[--secure | -s]
[--user admin_user]
[--passwordfile file_name]
[--restype res_type]
[--steadypoolsize 8]
[--maxpoolsize 32]
[--maxwait 60000]
[--poolresize 2]
[--idletimeout 300]
[--isolationlevel isolation_level]
[--isisolationguaranteed]
[--isconnectvalidatereq=false]
[--validationmethod auto-commit]
[--validationtable tablename]
[--failconnection=false]
[--allownoncomponentcallers=false]
[--nontransactionalconnections=false]
[--description text]
[--property (name=value)[:name=value]*]
jdbc_connection_pool_id
# ${GLASSFISH}/bin/asadmin create-jdbc-connection-pool \
--datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource \
--host localhost \
--port 14848 \
--user lportal \
--restype javax.sql.DataSource \
--description "MySQL Liferay Portal 5.0.1" \
--property ServerName=localhost:Password=lportal:DatabaseName=lportal:User=lportal:Port=3306:PortNumber=3306:LoginTimeout=0:ProfileSql=false \
MySQL_Liferay
Please enter the admin password>
Command create-jdbc-connection-pool executed successfully.
Resources/JDBC/JDBC Resources:
If you are using the Glassfish web-based admin console,
go to Resources/JDBC/JDBC Resources, create a JDBC resource with the
JNDI name jdbc/LiferayPool, and associate it with the connection pool
created in the previous step. Here is the asadmin command
to perform the same function.
Usage: ${GLASSFISH}/bin/asadmin create-jdbc-resource
--connectionpoolid id
[--terse=false]
[--echo=false]
[--interactive=true]
[--host localhost]
[--port 4848|4849]
[--secure | -s]
[--user admin_user]
[--passwordfile file_name]
[--enabled=true]
[--description text]
[--target target(Default server)]
[--property (name=value)[:name=value]*]
jndi_name
# ${GLASSFISH}/bin/asadmin create-jdbc-resource \
--connectionpoolid MySQL_Liferay \
--host localhost \
--port 14848 \
--user lportal \
--enabled=true \
--description "Liferay Portal 5.0.1 Pool" \
jdbc/LiferayPool
Please enter the admin password>
Command create-jdbc-resource executed successfully.
Resources/JavaMail Sessions:
If you are using the Glassfish web-based admin console,
go to Resources/JavaMail Sessions and create a JavaMail resource with
the JNDI name mail/MailSession. Here is the asadmin command
to perform the same function.
Usage: ${GLASSFISH}/bin/asadmin create-javamail-resource
--mailhost hostname
--mailuser username
--fromaddress address
[--terse=false]
[--echo=false]
[--interactive=true]
[--host localhost]
[--port 4848|4849]
[--secure | -s]
[--user admin_user]
[--passwordfile file_name]
[--storeprotocol imap]
[--storeprotocolclass com.sun.mail.imap.IMAPStore]
[--transprotocol smtp]
[--transprotocolclass com.sun.mail.smtp.SMTPTransport]
[--debug=false]
[--enabled=true]
[--description text]
[--property (name=value)[:name=value]*]
[--target target(Default server)]
jndi_name
# ${GLASSFISH}/bin/asadmin create-javamail-resource \
--mailhost localhost \
--mailuser root@localhost \
--fromaddress root@localhost \
--host localhost \
--port 14848 \
--user lportal \
--enabled=true \
--description "Liferay Portal Mail" \
mail/MailSession
Please enter the admin password>
Command create-javamail-resource executed successfully.
Restart Glassfish:
# ${GLASSFISH}/bin/asadmin stop-domain lportal
# ${GLASSFISH}/bin/asadmin start-domain lportal
Deploy Liferay:
Deploy the Liferay WAR file to the server with the context root /.
Usage: ${GLASSFISH}/bin/asadmin deploy
[--terse=false]
[--echo=false]
[--interactive=true]
[--host localhost]
[--port 4848|4849]
[--secure | -s]
[--user admin_user]
[--passwordfile file_name]
[--virtualservers virtual_servers]
[--contextroot context_root]
[--force=true]
[--precompilejsp=false]
[--verify=false]
[--name component_name]
[--upload=true]
[--retrieve local_dirpath]
[--dbvendorname dbvendorname]
[--createtables=true|false | --dropandcreatetables=true|false]
[--uniquetablenames=true|false]
[--deploymentplan deployment_plan]
[--enabled=true]
[--generatermistubs=false]
[--availabilityenabled=false]
[--libraries jar_file[(pathseparator)jar_file]*]
[--target target(Default server)]
filepath
# ${GLASSFISH}/bin/asadmin deploy \
--host localhost \
--port 14848 \
--user lportal \
--contextroot / \
--precompilejsp=false \
--verify=false \
--name "Liferay-Portal-5.0.1" \
--enabled=true \
${LIFERAY}/liferay-portal-5.0.1.war
You can also deploy liferay by copying the ${LIFERAY}/liferay-portal-5.0.1.war file
to the autodeploy sub-directory of the glassfish domain:
${GLASSFISH}/domains/lportal/autodeploy
# cp ${LIFERAY}/liferay-portal-5.0.1.war ${GLASSFISH}/domains/lportal/autodeploy
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.
For faster application load times, precompile the JSPs (this will take several minutes).
Do not run the verifier, as the sun-web.xml file does not match its
DTD and will cause a deployment failure.
The liferay portal is ready to run:
- Connect to the portal on http://localhost:18080.
- Login as the default administrator: test@liferay.com
- Password is test