As a followup to my previous article detailing how to deploy Liferay in a Jboss managed domain, I decided that I should build on that and explain how to deploy the Apache Solr enterprise search engine to a separate node within the Jboss-managed domain. This will explain how to deploy the Solr web application to a separate server within the same JBoss installation as Liferay and how to configure and deploy the Liferay solr-web.war plugin into Liferay.

NOTE: Liferay currently only supports Apache Solr version 1.4.1; more recent versions of the Solr application will not work without extensive modification of the Liferay Solr plugin.

This post assumes that you have a stock installation of JBoss 7.0.2 placed in /opt/liferay/jboss-7.0.2. 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.
  • ${SOLR_HOME}: Solr’s “home” directory; the directory containing Solr configuration and index information. I will be using /opt/solr-home/solr-01 for this location.
  • ${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.

Create the JBoss server group and server for hosting the Solr server

First things first; it is necessary to create a separate JBoss server group and server for hosting the Apache Solr application; you do not want the Solr instance residing in the same JVM as the Liferay instance, for many reasons.

  1. Open the ${JBOSS_HOME}/domain/configuration/domain.xml file and locate the <server-groups /> container. Add the following content to create a server group for your Solr instance:
    <server-group name="solr-server-group" profile="default">
        <jvm name="default">
            <heap size="128m" max-size="384m"/>
        </jvm>
        <socket-binding-group ref="standard-sockets"/>
    </server-group>
    
  2. Open the ${JBOSS_HOME}/domain/configuration/host.xml file and locate the <servers /> container. Add the following to add a server for your Solr instance:
    <server name="solr-01" group="solr-server-group">
        <system-properties>
            <property name="solr.solr.home" value="${SOLR_HOME}" />
        </system-properties>
        <socket-binding-group ref="standard-sockets" port-offset="150"/>
        <jvm name="default" />
    </server>
    
  3. Stop and start the target JBoss instance.

Run through basic configuration for the Solr instance

The initial configuration for Apache Solr consists of extracting the WAR and configuration files for Solr and deploying them to the appropriate locations.

  1. Download and unpack the apache-solr-1.4.1 archive from the Apache download site.
  2. From the unpacked apache-solr-1.4.1 directory, copy the contents of the example/solr/ directory into ${SOLR_HOME}.
  3. Copy the apache-solr-1.4.1.war file from the dist directory in the unpacked apache-solr-1.4.1 directory to /tmp/solr.war.
  4. Start the JBoss administration CLI by issuing the following command from the ${JBOSS_HOME}/bin directory:
    ./jboss-admin.sh --connect
    
  5. Deploy the apache-solr-1.4.1.war file by issuing the following command at the JBoss administration client prompt:
    deploy /tmp/solr.war --server-groups=solr-server-group
    

Customize the solr-web.war Liferay plugin

  1. Download the solr-web plugin file from Liferay (at the time of this writing, the war file was named solr-web-6.1.0.1-ce-ga1-20120106155615760.war).
  2. Copy the solr-web.war file to ${LIFERAY_HOME}/deploy. This will cause Liferay to process the web plugin and expand it to ${JBOSS_HOME}/standalone/deployments/solr-web.war.
  3. From the expanded ${JBOSS_HOME}/standalone/deployments/solr-web.war directory, copy the schema.xml file located in WEB-INF/conf/ into the ${SOLR_HOME}/conf/ directory.
  4. Stop and start the JBoss server to force the Solr instance to pick up the new schema.xml
  5. Unpack the Liferay unbundled WAR file to /tmp/liferay-unbundled
  6. From /tmp/liferay-unbundled/WEB-INF/lib directory, copy the following jars into ${JBOSS_HOME}/standalone/deployments/solr-web.war/WEB-INF/lib/:
    • commons-codec.jar
    • commons-httpclient.jar
    • commons-logging.jar
  7. Open the ${JBOSS_HOME}/standalone/deployments/solr-web.war/WEB-INF/classes/META-INF/solr-spring.xml file and modify the <constructor /> element as follows:
    <constructor-arg type="java.lang.String" value="http://localhost:8230/solr" />
    
  8. Jar the contents of the ${JBOSS_HOME}/standalone/deployments/solr-web.war/ directory into /tmp/solr-web.war
  9. Start the JBoss administration CLI by issuing the following command from the ${JBOSS_HOME}/bin directory:
    ./jboss-admin.sh --connect
    
  10. Deploy the solr-web.war file by issuing the following command at the JBoss administration client prompt:
    deploy /tmp/solr-web.war --server-groups=liferay-server-group
    
Share This