Liferay Home is three folders above your GlassFish domain folder.
For example, if your domain location is
/glassfish-4.0-web/glassfish4/glassfish/domains/domain1
, Liferay Home is
/glassfish-4.0-web/glassfish4/
.
If you don’t already have an existing GlassFish server, we recommend that you download a Liferay/GlassFish bundle from the Help Center. If you have an existing GlassFish server or would like to install Liferay on GlassFish manually, please follow the steps below.
Before you begin, make sure you have downloaded the latest Liferay .war
file
and Liferay Portal dependencies from
the Help Center.
The Liferay .war
file should be called liferay-portal-6.2.x-<date>.war
and
the dependencies file should be called
liferay-portal-dependencies-6.2.x-<date>.zip
.
These instructions assume that you are running the latest supported version of Glassfish (currently 4.0), have already configured a domain and server, and that you have access to the GlassFish administrative console.
Let’s start out by installing the JAR files you will need.
Dependency Jars
Liferay depends on jar files found in the Liferay Dependencies Archive. You should also have installed your database driver.
-
Navigate to the folder that corresponds to the domain in which you’ll be installing Liferay. Inside this folder is a sub-folder named
lib
(e.g./glassfish-3.1-web/glassfish3/glassfish/domains/domain1/lib
).Unzip the Liferay dependencies archive so that its
.jar
files are extracted into thislib
folder. -
Make sure the JDBC driver for your database is accessible to GlassFish as well. Obtain the JDBC driver for your version of the database server. In the case of MySQL, use
mysql-connector-java-{$version}-bin.jar
. You can download the latest MySQL JDBC driver from http://www.mysql.com/products/connector/. Extract the JAR file and copy it tolib
.
Terrific, you have your JAR files just where you need them. Next, we’ll configure your domain.
Domain Configuration
There are a couple of modifications you need to make in your domain to use Liferay Portal.
Before starting GlassFish, modify your domain’s configuration to do the following:
- Set the file encoding
- Set the user time-zone
- Set the preferred protocol stack
- Prevent the application server from setting static fields (final or non-final)
to
null
- Increase the default amount of memory available.
Modify
glassfish4/glassfish/domains/domain1/config/domain.xml
,
merging in the following JVM options into the current lists of JVM options
within any <java-config>
element in the file:
<jvm-options>-Dfile.encoding=UTF-8</jvm-options>
<jvm-options>-Djava.net.preferIPv4Stack=true</jvm-options>
<jvm-options>-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false</jvm-options>
<jvm-options>-Duser.timezone=GMT</jvm-options>
<jvm-options>-Xmx1024m</jvm-options>
<jvm-options>-XX:MaxPermSize=512m</jvm-options>
There may be multiple lists of JVM options in your domain.xml
file. For
example, by default, GlassFish’s
glassfish4/glassfish/domains/domain1/config/domain.xml
file contains two lists
of JVM options. There’s one list inside of the <config name="server-config">
element’s <java-config>
element and another inside of the <config name="default-config">
element’s <java-config>
element. In both lists of JVM
options, make sure that any existing options with values such as
-Dfile.encoding
, -Djava.net.preferIPv4Stack
,
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES
,
-Duser.timezone
, or -XX:MaxPermSize
are replaced with the new values listed
above.
For example, replace:
<jvm-options>-Xmx256m</jvm-options>
with this:
<jvm-options>-Xmx1024m</jvm-options>
Edit your domain1/config/server.policy
and append the following
lines to the end of the file:
grant {
permission java.security.AllPermission;
};
Delete, rename, or move the domain1/docroot/index.html
file to another
location to allow your Liferay Portal default page to be displayed.
Next, let’s get your database configured.
Database Configuration
If you want to use GlassFish to manage your domain’s data source, follow the instructions found in this section. If you want to use Liferay Portal to manage your data source, you can skip this section.
-
Start your domain’s application server if it is not already running.
-
Go to the GlassFish console URL: http://localhost:4848.
-
Under Common Tasks, navigate to Resources → JDBC → JDBC Connection Pools
-
Click New….
-
On the first screen (Step 1 of 2), enter the name
LiferayPool
for your connection pool, select thejavax.sql.ConnectionPoolDataSource
resource type, and select your database driver vendor (e.g.MySQL
). See the following figure: -
Click Next to advance to the next step in creating your JDBC connection pool.
-
From the top of this screen (Step 2 of 2), scroll down to the Additional Properties section.
-
Replace or add the following properties …
Url: the URL of your connection pool.
For example,
jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&emulateLocators=true
Note, if you are using the above example, you should specify the name of your database in place of
lportal
. Likewise, if your database is not on the same host as GlassFish, specify your the database server’s host name in place oflocalhost
. Lastly, specify your database type in place ofjdbc:mysql
and use the correct port (3306 is for MySQL).User: the name of your database user.
Password: your database user’s password.
-
Click Finish.
You should now see your
LiferayPool
connection pool listed under Resources → JDBC → JDBC Connection Pools -
Test your connection by selecting your
LiferayPool
connection pool and clicking Ping.If you get a message stating Ping Succeeded, you’ve succeeded in setting up a connection pool of your data source!
-
Now, you’ll setup a JDBC resource to refer to the
LiferayPool
connection pool you just created. -
Navigate to Resources → JDBC → JDBC Resources to show the current JDBC resources listed by their JNDI names.
-
Click New….
-
Set the JNDI name to
jdbc/LiferayPool
and selectLiferayPool
as the pool name. -
Click OK.
Congratulations! You’ve now configured your domain’s data source on GlassFish!
Mail Configuration
If you want to use GlassFish to manage your mail session, follow GlassFish’s
documentation on configuring a JavaMail session with a JNDI name of
mail/MailSession
. If you want to use Liferay Portal to manage your mail
session, you can skip this step.
Domain Configuration - Continued
Let’s tie up some loose ends with regards to Liferay being able to access your database and mail session.
-
Shutdown your domain’s application server if it is currently running.
-
If you are using Glassfish to manage your data source, create a
portal-ext.properties
file in the Liferay Home folder mentioned at the beginning of this GlassFish installation section and add the following to yourportal-ext.properties
file in your Liferay Home to refer to your data source:jdbc.default.jndi.name=jdbc/LiferayPool
Otherwise, if you are using Liferay Portal to manage your data source, follow the instructions in the Deploy Liferay section for using the setup wizard.
-
If want to use Liferay Portal to manage your mail session, you can configure the mail session within Liferay Portal. That is, after starting your portal as described in the Deploy Liferay section, go to Control Panel → Server Administration → Mail and enter the settings for your mail session.
Otherwise, if you are using GlassFish to manage your mail session, add the following to your
portal-ext.properties
file to reference that mail session:mail.session.jndi.name=mail/MailSession
Liferay will now be able to communicate with your database and mail session.
PACL Configuration
To enable PACL on GlassFish, you need to make some security configurations.
First, enable the security manager by editing
glassfish/domains/domain1/config/domain.xml
and make sure it contains the
following:
<java-config ...>
...
<jvm-options>-Djava.security.manager</jvm-options>
...
</java-config>
Next, add the required permissions to the server policy configuration file:
glassfish/domains/domain1/config/server.policy
. These include the following:
grant {
permission java.security.AllPermission;
};
Now let’s go ahead and deploy Liferay.
Deploy Liferay
-
Start your domain’s application server.
-
Go to the GlassFish console URL: http://localhost:4848
-
Click Applications in the tree on the left.
-
Click Deploy.
-
Under Packaged File to Be Uploaded to the Server, click Choose File and browse to the location of the Liferay Portal
.war
file. Enter Context Root:/
-
Enter Application Name:
liferay-portal
-
Click OK.
Once you have deployed Liferay via GlassFish’s administrative console, restart GlassFish.
Your installation of Liferay Portal on GlassFish is complete!