I setup Liferay on Glassfish to support some JSR-168 Portlets that I'm working on. Here are my notes on getting Liferay running. I installed this configuration on my Apple MacBook Pro with Tiger (10.4).
pre-condition:
- glassfish v2 installed
- mysql 5.0.41 insatlled
- apache log4j jar file
- mysql jdbc driver jar file
variables:
- export GLASS_HOME=/usr/local/glassfish_v2
- export LIFERAY_HOME=/work/Software/Projects/liferay
- export MYSQL_HOME=/usr/local/mysql
download software:
- Create a directory into which to store and extract the download files ${LIFERAY_HOME}
- http://www.liferay.com/web/guest/downloads/additional.
- Download the Liferay Portal 4.X.Y WAR file for Servlet 2.4 to the directory: ${LIFERAY_HOME}
- Download the Liferay Portal 4.X.Y Dependencies file and unzip to the dependencies subdirectory: ${LIFERAY_HOME}/dependencies
- Download the Liferay Portal 4.X.Y SQL Scripts file and unzip to the sql subdirectory: ${LIFERAY_HOME}/sql
- Download the Liferay Plugins SDK 4.X.Y file and unzip to the sdk subdirectory: ${LIFERAY_HOME}
- Download the Liferay Portal 4.X.Y Web Services Client and unzip to the ws-client subdirectory: ${LIFERAY_HOME}/ws-client
- Download the Liferay Portal 4.X.Y JavaDocs and unzip to the doc subdirectory: ${LIFERAY_HOME}/doc
- Download Apache Log4j store in /work/Software/Library/Log4j, http://logging.apache.org/log4j/1.2/download.html
configuration:
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 (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, and DELETE permissions on all tables in the lportal database.
# mysql -uroot -ppassword < ${LIFERAY_HOME}/sql/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 |
/usr/local/glassfish_v2/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 is running.
asadmin stop-domain lportal
Copy the Liferay dependencies to the Glassfish domains/lportal/lib subdirectory.
cp portal-kernel.jar portal-service.jar portlet.jar /usr/local/glassfish_v2/domains/liferay/lib
Copy the xercesImpl.jar file from the Liferay sdk/lib subdirectory to the Glassfish domains/lportal/lib subdirectory.
cp xercesImpl.jar /usr/local/glassfish_v2/domains/liferay/lib
Copy any required bridges (e.g. jsf-portlet.jar) to the Glassfish domains/lportal/lib subdirectory.
Copy the JDBC driver for your database to the domains/lportal/lib directory.
cp mysql-jdbc.jar /usr/local/glassfish_v2/domains/liferay/lib
Copy the Log4j jar to the domains/lportal/lib directory.
cp log4j-1.2.15.jar /usr/local/glassfish_v2/domains/liferay/lib
Start Glassfish and login to the Admin Console.
asadmin start-domain lportal
Go to Resources/JDBC/Connection Pools and create a connection pool to connect to the lportal database.
asadmin create-jdbc-connection-pool Usage: 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 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 4.4.2" --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.
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.
asadmin create-jdbc-resource Usage: 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 asadmin create-jdbc-resource --connectionpoolid MySQL_Liferay --host localhost --port 14848 --user lportal --enabled=true --description "Liferay Portal 4.4.2 Pool" jdbc/LiferayPool Please enter the admin password> Command create-jdbc-resource executed successfully.
Go to Resources/JavaMail Sessions and create a JavaMail resource with the JNDI name mail/MailSession.
asadmin create-javamail-resource Usage: 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 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.
Deploy the Liferay WAR file to the server with the context root /.
./asadmin deploy Usage: 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 asadmin deploy --host localhost --port 14848 --user lportal --contextroot / --precompilejsp=false --verify=false --name "Liferay-Portal-4.4.2" --enabled=true /work/Software/Projects/liferay/liferay-portal-4.4.2.war
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