(888) 685-3101 ext. 2

Well, Liferay 6.1 CE GA1 is out, and anyone who uses Liferay should be very excited. This release sports a bunch of new features, including significantly improved site staging and publishing, dynamic data lists, improved mobility/social capabilities, faceted search, the ability to connect to discrete document repositories, and a slew of improvements to basic portal usage. By default, the Liferay 6.1 CE GA1 bundle that ships with JBoss comes configured to run in JBoss as a standalone node; however, if you’re looking to use some of the scaling and management features included in JBoss 7.0, you’ll want to run Liferay as a managed node in a JBoss domain. Below, I’ll run through the process of configuring JBoss and Liferay to run in a managed domain setup; the details should be applicable to Liferay 6.1 EE as well, once it’s released. I’ll cover any changes between the two in a later blog post, if necessary.

This post assumes that you have a stock installation of JBoss 7.0.2 placed in /opt/liferay/jboss-7.0.2, and that you will be installing using the Liferay war distribution + dependencies ZIP file. The following variables will be used inline for brevity:

  • ${JBOSS_HOME}: The root directory for the JBoss installation; for my purposes, this would be /opt/liferay/jboss-7.0.2.
  • ${LIFERAY_HOME}: Liferay’s “home” directory; the directory containing the Liferay “deploy”, “data”, and “license” directories. By default, this is the parent directory of the application server installation directory; I will be using this default (/opt/liferay) for this document.

Configure JBoss modules for portal dependencies

JBoss 7.0.2 uses a completely updated model for managing classloading; the details of this are out of the scope of this document. Suffice it to say that it is necessary to define modules for any libraries that must be accessible to multiple applications deployed on the same JBoss instance; for Liferay, this includes the files shipped in the Liferay Portal Dependencies distribution.

  1. Create the following directory:
    ${JBOSS_HOME}/modules/com/liferay/portal/main
    
  2. Unpack all jar files distributed in the Liferay portal dependencies archive to the directory created above.
  3. Create a file called module.xml in the directory created above. Paste the following contents into that file:
    <?xml version="1.0"?>
    <module xmlns="urn:jboss:module:1.0" name="com.liferay.portal">
            <resources>
                    <resource-root path="portal-service.jar" />
                    <resource-root path="portlet.jar" />
            </resources>
            <dependencies>
                    <module name="javax.api" />
                    <module name="javax.mail.api" />
                    <module name="javax.servlet.api" />
                    <module name="javax.servlet.jsp.api" />
                    <module name="javax.transaction.api" />
            </dependencies>
    </module>
    

Set up the Portal Authentication module

  1. In ${JBOSS_HOME}/domain/configuration/domain.xml, add the following content to the <security-domains /> container within the jboss:domain:security:1.0 subsystem:
    <security-domain name="PortalRealm">
        <authentication>
            <login-module
            code="com.liferay.portal.security.jaas.PortalLoginModule"
            flag="required"/>
        </authentication>
    </security-domain>
    

Modify the JBoss Web subsystem

We need to modify the web subsystem to allow Liferay to serve as the root context for the JBoss server, and to turn JSP recompilation on (obviously, the second item is not recommended for a production system).

  1. In ${JBOSS_HOME}/domain/configuration/domain.xml, locate the jboss:domain:web:1.0 subsystem.
  2. Modify the following section to disable the welcome root; you may also wish to redefine the aliases to the correct FQDN for your system:
    <virtual-server name="default-host" enable-welcome-root="false">
        <alias name="localhost" />
        <alias name="example.com" />
    </virtual-server>
    
  3. Add the following content to the same <subsystem /> container to enable JSP recompilation:
    <configuration>
        <jsp-configuration development="true" />
    </configuration>
    

Configure the JVM defaults for Liferay servers

  1. Edit ${JBOSS_HOME}/bin/domain.conf and add the following line to the end of the file, replacing the timezone declaration with the correct timezone for your server:
    JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT"
    
  2. Open the ${JBOSS_HOME}/domain/configuration/domain.xml file and locate the <server-groups /> container. Comment or remove the default server-group entries, and add the following content to create a server group for your Liferay instance(s):
    <server-group name="liferay-server-group" profile="default">
        <jvm name="default">
            <heap size="1024m" max-size="2048m"/>
            <permgen size="384m" max-size="512m" />
        </jvm>
        <socket-binding-group ref="standard-sockets"/>
    </server-group>
    

    NOTE: the “standard-sockets” socket binding group should be used for a regular standalone Liferay instance. If you’re looking to set up a JBoss cluster, you should use the “ha-sockets” socket binding group. Additional configuration is required for clustering which will not be covered in this document.

  3. Open the ${JBOSS_HOME}/domain/configuration/host.xml file and locate the <servers /> container. Comment or remove all default server entries, and add the following to add a server for your Liferay instance:
    <server name="liferay-01" group="liferay-server-group">
        <jvm name="default" />
    </server>
    

Create a JNDI datasource for your Liferay server instance

This section assumes that you are using Mysql as your database backend; the same concepts apply for any other database engine. Make certain to use an XA-enabled database driver if at all possible; configuration for non-XA sources would be slightly different.

  1. Create a JBoss module directory for your JDBC database driver (e.g. ${JBOSS_HOME}/modules/com/mysql/main).
  2. Place the JAR file containing your database driver in the directory created above (e.g. ${JBOSS_HOME}modules/com/mysql/main/mysql-connector-java-5.1.18-bin.jar)
  3. Create a module.xml file in the directory created above with appropriate contents for your JDBC driver. For example:
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="com.mysql">
      <resources>
        <resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
      </resources>
      <dependencies>
        <module name="javax.api"/>
      </dependencies>
    </module>
    
  4. In ${JBOSS_HOME}/domain/configuration/domain.xml, locate the urn:jboss:domain:datasources:1.0 subsystem. Add the following to the <drivers /> container to make your JDBC driver available to the application server:
    <driver name="com.mysql" module="com.mysql">
        <xa-datasource-class>
    	com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
        </xa-datasource-class>
    </driver>
    
  5. In the same subsystem, add the following to the <datasources /> container to create a datasource using the driver created above:
    <datasource jndi-name="java:jboss/datasources/LiferayDS"
        pool-name="LiferayDS" enabled="true"
        jta="true" use-java-context="true" use-ccm="true">
        <connection-url>DATABASE_CONNECTION_URL_HERE</connection-url>
        <driver>com.mysql</driver>
        <pool>
            <prefill>false</prefill>
            <use-strict-min>false</use-strict-min>
            <flush-strategy>FailingConnectionOnly</flush-strategy>
        </pool>
        <security>
            <user-name>DATABASE_USERNAME_HERE</user-name>
            <password>DATABASE_PASSWORD_HERE</password>
        </security>
    </datasource>
    
  6. Make certain that the database and user referenced in the above datasource definition exists.
  7. In ${LIFERAY_HOME}, create a portal-ext.properties file referencing the above datasource name, as follows:
    jdbc.default.jndi.name=java:jboss/datasources/LiferayDS
    

Deploy the ROOT.war application to the JBoss managed server group

  1. Unpack the Liferay war to /tmp/root-unpacked
  2. Delete the eclipselink.jar file from /tmp/root-unpacked/WEB-INF/lib/
  3. Download the Apache Tomcat Log4j JULI JAR file from the “extras” section of the Apache Tomcat download site (http://tomcat.apache.org/download-70.cgi)
  4. Place the tomcat-juli.jar file in /tmp/root-unpacked/WEB-INF/lib/
  5. Create the ROOT.war WAR file from the root-unpacked directory.
  6. Start the JBoss managed domain by executing the following command from the ${JBOSS_HOME}/bin directory:
    ./domain.sh -b 0.0.0.0
    
  7. Start the JBoss administration CLI by issuing the following command from the ${JBOSS_HOME}/bin directory:
    ./jboss-admin.sh --connect
    
  8. Deploy the /tmp/ROOT.war file by issuing the following command at the JBoss administration client prompt:
    deploy /tmp/ROOT.war --server-groups=liferay-server-group
    

Done!

You should now be able to navigate to liferay at http://localhost:8080/ to proceed with the Liferay server setup wizard. If you wish to skip the setup wizard process, add the following properties to the portal-ext.properties file created above:

liferay.home=/opt/liferay
admin.email.from.name=Test User
admin.email.from.address=test@liferay.com
default.admin.first.name=Test
default.admin.last.name=User
default.admin.email.address=test@liferay.com
default.admin.screen.name=test
company.default.name=YOUR COMPANY NAME HERE
company.default.locale=en_US
setup.wizard.enabled=false
Share This