« Back to Legacy Deployments

Building from source on Glassfish 2

Table of Contents [-]

Introduction #

This article is a step by step guide to build Liferay from source code and to deploy it on Glassfish.

  1. Download GlassFish v2 Update Release 2 (UR2). Install it
    1. java -Xmx256m -jar glassfish-installer-v2ur2-b04-windows.jar
    2. ant -f setup.xml
  2. If you intend to use default database i.e. HSQL go to Step 10.
  3. If Database is MySQL, Download MySQL and MySQL connector jar.
  4. Install MySQL (Refer installation specifics below in Notes section)
  5. Create database 'lportal' with user 'lportal' and grant system/administrator level privileges. This is a sample default user. One can create other users and try it out by modifying Liferay Source Code. For Details refer MySQL Documentation
  6. Alternatively, follow these steps
    1. Login to MySQL as 'root' and create database lportal;
    2. use lportal;
    3. create user lportal;
    4. set password for 'lportal'@'localhost' = password('lportal');
    5. grant all privileges on . to 'lportal'@'localhost' identified by 'lportal'
    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. While doing so, one can specify the database to connect to.
  7. After login to GF admin console, 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. Alternatively, you can use asadmin cli as mentioned below in the note.
  8. Copy MySQL connector jar in the glassfish/domains/domain1/lib
  9. Stop Glassfish
  10. Check out Liferay Source Code.
  11. Download apache-ant-1.7.0. Extract it
  12. set ANT_HOME to apache-ant-1.7.0
  13. Use JDK 1.5 or above and set it in Path.
  14. Go to Liferay source code directory and modify appserver.properties. Make sure you specify the directory in which glassfish is installed and NOT the glassfish home. For example, if glassfish is installed in f:\glassfish, then in the app.server.properties, please specify f:/(forward slash on Windows). The name of the glassfish folder has to be "glassfish". Comment tomcat entry :-)
  15. In app.server.properties , please specify the glassfish version viz. v2 or v3. Please change it to reflect as per the glassfish download that one has.
  16. Go to Liferay Source Code Directory and run ant -f build.xml all
  17. Once, build is successful, the build process will create the necessary jars and copy them to Glassfish Domain.
  18. On UNIX/Linux/Cygwin you can verify the proper install locations of the jar file within the
    glassfish
    directory by using some
    find
    command magic

$ find ./glassfish -type f -cmin -60 -ls 614495 633 -rw-r--r-- 1 george users 643806 Apr 28 10:38 ./glassfish/domains/domain1/lib/hsql.jar 610313 473 -rw-r--r-- 1 george users 482699 Apr 28 10:37 ./glassfish/domains/domain1/lib/portal-kernel.jar 614500 424 -rw-r--r-- 1 george users 431283 Apr 28 10:38 ./glassfish/domains/domain1/lib/postgresql.jar 614493 8 -rw-r--r-- 1 george users 5848 Apr 28 10:38 ./glassfish/domains/domain1/lib/annotations.jar 614497 48 -rw-r--r-- 1 george users 48725 Apr 28 10:38 ./glassfish/domains/domain1/lib/portlet.jar 614646 1177 -rw-r--r-- 1 george users 1203860 Apr 28 10:40 ./glassfish/domains/domain1/lib/xercesImpl.jar 614494 336 -rw-r--r-- 1 george users 343833 Apr 28 10:38 ./glassfish/domains/domain1/lib/portlet-container.jar 614499 96 -rw-r--r-- 1 george users 98213 Apr 28 10:38 ./glassfish/domains/domain1/lib/container.jar 610314 1866 -rw-r--r-- 1 george users 1907215 Apr 28 10:37 ./glassfish/domains/domain1/lib/portal-service.jar 614498 40 -rw-r--r-- 1 george users 40538 Apr 28 10:38 ./glassfish/domains/domain1/lib/saw-api.jar 614647 384 -rw-r--r-- 1 george users 391834 Apr 28 10:40 ./glassfish/domains/domain1/lib/log4j.jar 614645 16 -rw-r--r-- 1 george users 15048 Apr 28 10:40 ./glassfish/domains/domain1/lib/ccpp.jar 614496 529 -rw-r--r-- 1 george users 536609 Apr 28 10:38 ./glassfish/domains/domain1/lib/mysql.jar 614649 72379 -rw-r--r-- 1 george users 74042800 Apr 28 10:43 ./glassfish/domains/domain1/autodeploy/liferay-portal.war 614507 432 -rw-r--r-- 1 george users 441729 Apr 28 10:38 ./glassfish/domains/domain1/autodeploy/tunnel-web.war }}}

  1. Since Liferay will attempt to use the embedded HSQL database by default, create a
    portal-ext.properties
    file to avoid this and point Liferay to MySQL

$ cd glassfishv3/glassfish/domains/domain1/applications/liferay-portal/WEB-INF/classes $ vim portal-ext.properties ... $ cat portal-ext.properties jdbc.default.jndi.name=jdbc/LiferayPool database.mysql.engine=InnoDB }}}

  1. Restart Glassfish. Wait for 3 minutes, since Liferay compiles JSPs. One can turn off JSP Compilation if required.

Hope this helps!!! Please try it out and let me know if we need to modify these steps anywhere.

Start using Liferay with Glassfish!!!

Notes #

  1. These installation steps are on a fresh glassfish installation.
  2. For those who want to get quick started without getting their hands dirty,but want to do it with Glassfish, there is also a Liferay bundle with Glassfish available for download here
  3. Install MySQL with detailed configuration. That way one will have better control especially multilingual etc./firewall blocking/unblocking
  4. If you have tried an unsuccesfull install of MySQL and unable to install again, please uninstall, delete the MySQL installation directory and re-install MySQL
  5. When MySQL is successfully installed, log on as "root" and create user lportal with lportal(password) and grant privileges.
  6. If you intend to create connection pool faster, you may follow alternatively the below method:
    1. Create mysql_liferay_connection_pool.xml
    2. Add the following contents to it

<resources> <jdbc-connection-pool name="LiferayPool" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" res-type="javax.sql.DataSource"> <property name="user" value="lportal"/> <property name="password" value="lportal"/> <property name="url" value="jdbc:mysql://localhost:3306/lportal"/> </jdbc-connection-pool> <jdbc-resource enabled="true" jndi-name="jdbc/LiferayPool" object-type="user" pool-name="LiferayPool"/> </resources> }}}

  1. Now run following command in glassfish/bin directory:
          asadmin add-resources <location-of-resource-file>/mysql_liferay_connection_pool.xml
0 Attachments
42448 Views
Average (0 Votes)
The average rating is 0.0 stars out of 5.
Comments
Threaded Replies Author Date
This is my mysql_liferay_connection_pool.xml ... Ayaz Pasha September 10, 2008 12:59 AM
The error free... Ayaz Pasha September 10, 2008 5:29 AM

This is my mysql_liferay_connection_pool.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE domain PUBLIC "-//Sun Microsystems Inc.//DTD Application Server 9.1 Domain//EN" "http://www.sun.com/software/appserver/dtds/sun-domain_1_3.dtd">
<resources>
<jdbc-connection-pool
name="LiferayPool"
datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
res-type="javax.sql.DataSource">
<property name="user" value="root"/>
<property name="password" value="lportal"/>
<property name="url" value="jdbc:mysql://localhost:3306/lportal"/>
</jdbc-connection-pool>
<jdbc-resource
enabled="true"
jndi-name="jdbc/LiferayPool"
object-type="user"
pool-name="LiferayPool"/>
</resources>

When I tried giving the command 'asadmin add-resources <location-of-resource-file>/mysql_liferay_connection_pool.xml' I get this error


system1@system1-desktop:~/project/glassfish/bin$ ./asadmin add-resources /home/system1/Desktop/mysql_liferay_connection_pool.xml
Operation 'createResource' failed in 'resources' Config Mbean.
Target exception message: Document root element "resources", must match DOCTYPE root "domain".
CLI137 Command add-resources failed.

I am stuck here, any workaround please....
Posted on 9/10/08 12:59 AM.
The error free mysql_liferay_connection_pool.xml is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems Inc.//DTD Application Server 9.1 Domain//EN" "http://www.sun.com/software/appserver/dtds/sun-domain_1_3.dtd">
<resources>
<jdbc­-connection-pool
name="LiferayPool"
datasource-classname="com.mysql.jdbc.jdbc2.opt­ional.MysqlDataSource"
res-type="javax.sql.DataSource">
<property name="user" value="root"/>
<property name="password" value="lportal"/>
<property name="url" value="jdbc:mysql://localhost:3306/lportal"/>
</jdbc-connection-pool>
<jdbc-resour­ce
enabled="true"
jndi-name="jdbc/LiferayPool"
object-type="user"
pool-name="Liferay­Pool"/>
</resources>
Posted on 9/10/08 5:29 AM.