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
Comments:

what's the advantage of this over using the pre-bundled Liferay 5.0 + GFv2 from the downlaods page?

http://sourceforge.net/project/showfiles.php?group_id=49260&package_id=42607
and
http://downloads.sourceforge.net/lportal/liferay-portal-glassfish-windows-5.0.1.jar?modtime=1208196402&big_mirror=1

Posted by Eduardo Pelegri-Llopart on May 14, 2008 at 03:00 PM CDT #

Great question. I should have written an introductory paragraph to explain why I was going through this manual process to deploy Liferay on glassfish, sorry. If you are going to install Liferay with Glassfish together, then the pre-bundled process that you mentioned is "the way to go". In my situation, I already had Glassfish (v2) deployed and running other applications. I wanted to add Liferay to this existing Glassfish installation and use a new domain called "lportal".

Posted by Scott Fehrman on May 14, 2008 at 03:16 PM CDT #

Makes sense to me! - eduard/o

Posted by Eduardo Pelegri-Llopart on May 14, 2008 at 04:15 PM CDT #

send me to my eMail java code plz

Posted by ashraf zeb on May 15, 2008 at 06:25 AM CDT #

This sounds really good. However, I do have a vital question.

Can you config liferay for an Oracle 10g express edition DB? can you email me about this.

Posted by Daniel Crain on July 27, 2009 at 12:38 AM CDT #

Daniel,
I don't know ... I have tried this or researched it.

Posted by Scott Fehrman on July 27, 2009 at 02:30 AM CDT #

Hi I am trying to deploy liferay 5.1.2 on sun application server 8.2. But when I am trying to deploy on server it gives following error

_____________________console error start__________________________

[#|2010-03-09T11:48:38.362+0530|SEVERE|sun-appserver-pe8.2|org.springframework.web.context.ContextLoader|_ThreadID=10;|Context initialization failed
java.lang.NoSuchMethodError: org.apache.commons.collections.IteratorUtils.emptyIterator()Lorg/apache/commons/collections/ResettableIterator;
at org.apache.commons.configuration.PropertyConverter.toIterator(PropertyConverter.java:882)
at org.apache.commons.configuration.AbstractConfiguration.addPropertyValues(AbstractConfiguration.java:416)
at org.apache.commons.configuration.AbstractConfiguration.addProperty(AbstractConfiguration.java:389)
at com.germinus.easyconf.AggregatedProperties.addIncludedPropertiesSources(AggregatedProperties.java:215)
at com.germinus.easyconf.AggregatedProperties.addFileProperties(AggregatedProperties.java:180)
at com.germinus.easyconf.AggregatedProperties.addPropertiesSource(AggregatedProperties.java:140)
at com.germinus.easyconf.AggregatedProperties.addBaseFileName(AggregatedProperties.java:116)
at com.germinus.easyconf.ConfigurationLoader.readPropertiesConfiguration(ConfigurationLoader.java:54)
at com.germinus.easyconf.ComponentConfiguration.getAvailableProperties(ComponentConfiguration.java:152)
at com.germinus.easyconf.ComponentConfiguration.getProperties(ComponentConfiguration.java:140)
at com.liferay.portal.configuration.ConfigurationImpl.getComponentProperties(ConfigurationImpl.java:271)
at com.liferay.portal.configuration.ConfigurationImpl.printSources(ConfigurationImpl.java:323)
at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:66)
at com.liferay.portal.util.PropsUtil.<init>(PropsUtil.java:88)
at com.liferay.portal.util.PropsUtil.<clinit>(PropsUtil.java:189)
at com.liferay.portal.spring.context.PortalApplicationContext.loadBeanDefinitions(PortalApplicationContext.java:63)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4010)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4522)
at com.sun.enterprise.web.WebModule.start(WebModule.java:241)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:847)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:483)
at org.apache.catalina.startup.Embedded.start(Embedded.java:894)
at com.sun.enterprise.web.WebContainer.start(WebContainer.java:741)
at com.sun.enterprise.web.PEWebContainer.startInstance(PEWebContainer.java:515)
at com.sun.enterprise.web.PEWebContainerLifecycle.onStartup(PEWebContainerLifecycle.java:54)
at com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:300)
at com.sun.enterprise.server.PEMain.run(PEMain.java:294)
at com.sun.enterprise.server.PEMain.main(PEMain.java:220)
|#]

[#|2010-03-09T11:48:38.379+0530|SEVERE|sun-appserver-pe8.2|javax.enterprise.system.container.web|_ThreadID=10;|WebModule[]Exception sending context initialized event to listener instance of class com.liferay.portal.spring.context.PortalContextLoaderListener
java.lang.NoSuchMethodError: org.apache.commons.collections.IteratorUtils.emptyIterator()Lorg/apache/commons/collections/ResettableIterator;
at org.apache.commons.configuration.PropertyConverter.toIterator(PropertyConverter.java:882)
at org.apache.commons.configuration.AbstractConfiguration.addPropertyValues(AbstractConfiguration.java:416)
at org.apache.commons.configuration.AbstractConfiguration.addProperty(AbstractConfiguration.java:389)
at com.germinus.easyconf.AggregatedProperties.addIncludedPropertiesSources(AggregatedProperties.java:215)
at com.germinus.easyconf.AggregatedProperties.addFileProperties(AggregatedProperties.java:180)
at com.germinus.easyconf.AggregatedProperties.addPropertiesSource(AggregatedProperties.java:140)
at com.germinus.easyconf.AggregatedProperties.addBaseFileName(AggregatedProperties.java:116)
at com.germinus.easyconf.ConfigurationLoader.readPropertiesConfiguration(ConfigurationLoader.java:54)
at com.germinus.easyconf.ComponentConfiguration.getAvailableProperties(ComponentConfiguration.java:152)
at com.germinus.easyconf.ComponentConfiguration.getProperties(ComponentConfiguration.java:140)
at com.liferay.portal.configuration.ConfigurationImpl.getComponentProperties(ConfigurationImpl.java:271)
at com.liferay.portal.configuration.ConfigurationImpl.printSources(ConfigurationImpl.java:323)
at com.liferay.portal.configuration.ConfigurationImpl.<init>(ConfigurationImpl.java:66)
at com.liferay.portal.util.PropsUtil.<init>(PropsUtil.java:88)
at com.liferay.portal.util.PropsUtil.<clinit>(PropsUtil.java:189)
at com.liferay.portal.spring.context.PortalApplicationContext.loadBeanDefinitions(PortalApplicationContext.java:63)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4010)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4522)
at com.sun.enterprise.web.WebModule.start(WebModule.java:241)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:847)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1086)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:483)
at org.apache.catalina.startup.Embedded.start(Embedded.java:894)
at com.sun.enterprise.web.WebContainer.start(WebContainer.java:741)
at com.sun.enterprise.web.PEWebContainer.startInstance(PEWebContainer.java:515)
at com.sun.enterprise.web.PEWebContainerLifecycle.onStartup(PEWebContainerLifecycle.java:54)
at com.sun.enterprise.server.ApplicationServer.onStartup(ApplicationServer.java:300)
at com.sun.enterprise.server.PEMain.run(PEMain.java:294)
at com.sun.enterprise.server.PEMain.main(PEMain.java:220)
|#]

_____________________console error end__________________________

How can I solve this problem.

Thanks
Ashwani Rawat

Posted by Ashwani Rawat on March 08, 2010 at 04:31 PM CST #

Post a Comment:
Comments are closed for this entry.
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