Wednesday May 14, 2008

Liferay 5.0 on existing Glassfish v2

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:

  1. Connect to the portal on http://localhost:18080.
  2. Login as the default administrator: test@liferay.com
  3. Password is test

Monday May 05, 2008

installing liferay on glassfish

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

About

Scott Fehrman

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Projects

No bookmarks in folder

Ref. Material

No bookmarks in folder