SolrJetty

Solr with Jetty

  1. Solr with Jetty
    1. Logging
    2. Configuring Solr Home with JNDI
    3. Multiple Solr Webapps
      1. Multiple Solr Webapps (pre-Jetty6)
      2. Multiple Solr Webapps (Jetty6)
    4. Caveats Noted By Users

Logging

For information about controlling JDK Logging (aka: java.util logging) in Jetty please consult the Jetty docs... [WWW] http://jetty.mortbay.org/jetty5/tut/logging.html

Configuring Solr Home with JNDI

Jetty Plus provides an addEnvEntry for configuring the JNDI property needed to specify your Solr Home directory.

To do this, use an "addWebApplication" that looks something like this...

  <Call name="addWebApplication">
    <Arg>/solr/*</Arg>
    <Arg>/your/path/to/the/solr.war</Arg>
    <Set name="extractWAR">true</Set> 
    <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>

    <Call name="addEnvEntry">
      <Arg>solr/home</Arg>
      <Arg type="String">/your/path/to/your/solr/home/dir</Arg>
    </Call>
  </Call>

Multiple Solr Webapps

Multiple Solr Webapps (pre-Jetty6)

Multiple solr instances can be run in a single Jetty Plus server by using multiple "addWebApplication" Call blocks with different values for the solr/home JNDI parameter...

  <Call name="addWebApplication">
    <Arg>/solr1/*</Arg>
    <Arg>/your/path/to/the/solr.war</Arg>
    <Set name="extractWAR">true</Set> 
    <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>

    <Call name="addEnvEntry">
      <Arg>solr/home</Arg>
      <Arg type="String">/your/path/to/your/solr/home/dir</Arg>
    </Call>
  </Call>

  <Call name="addWebApplication">
    <Arg>/solr2/*</Arg>
    <Arg>/your/path/to/the/solr.war</Arg>
    <Set name="extractWAR">true</Set> 
    <Set name="defaultsDescriptor">org/mortbay/jetty/servlet/webdefault.xml</Set>

    <Call name="addEnvEntry">
      <Arg>solr/home</Arg>
      <Arg type="String">/your/path/to/your/alternate/solr/home/dir</Arg>
    </Call>
  </Call>

Multiple Solr Webapps (Jetty6)

Jetty6 changed their context deployment syntax. Also, JNDI lookups, which are necessary for deploying multiple Solr instances require a special configuration. The default Jetty6 install does not include JNDI support, but it is easily tacked on. See this page: [WWW] JettyJNDI

New jetty.xml syntax:

    <New  class="org.mortbay.jetty.webapp.WebAppContext">
        <Arg><Ref id="contexts"/></Arg>
        <Arg><SystemProperty name="jetty.home" default="."/>/webapps/solr_app_1</Arg>
        <Arg>/solr_app_1</Arg>
        <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>
        <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
        <New class="org.mortbay.jetty.plus.naming.EnvEntry">
            <Arg>solr/home</Arg>
            <Arg type="java.lang.String"><SystemProperty name="jetty.home" default="."/>/webapps/solr_app_1/solr</Arg>
        </New>
    </New>

Where the variable for solr/home points to a directory containing a conf directory that in turn has a solrconfig.xml file.

Caveats Noted By Users

(7/2007 MattKangas) The recipe above didn't work for me with Jetty 6.1.3. Specifying "solr/home" via "<New class="...EnvEntry">" sets a GLOBAL value which gets evaluated after the full configuration is read, so the last setting wins.

Fortunately, I've found a solution that works well:

The "overrideDescriptor" settings will be applied AFTER it has been configured by the default descriptor and the WEB-INF/web.xml descriptor.

Alas, you still need the additional "Plus" .jars, and you need to define the "plusConfig" and set "ConfigurationClasses" appropriately. Without this, the overrideDescriptor won't be applied.

I'm glossing over a lot of details, so attached is a tarball with a known-good configuration that runs two Solr instances inside one Jetty container. I'm using Solr 1.2.0 and Jetty 6.1.3 respectively.

DEMO_multiple_webapps_jetty_6.1.3.tgz


(12/2008 KenEllinwood) I'm using Solr-1.3.0 and Jetty 6.1.12. Apparently the name for JNDI must have a leading slash now., eg., "solr/home" becomes "/solr/home" in the jetty config files. I was able to get the example up and running in a stand-alone Jetty without fiddling with the "overrideDescriptor" as described above. I'm using ContextDeployer in jetty.xml with the following context definition. Note the 3 argument syntax for the EnvEntry -- this appears to be a new requirement in more recent versions of Jetty. Also, I had to use an absolute path for the data directory in solrconfig.xml... not sure why.

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <Set name="contextPath">/solr</Set>
  <Set name="war">/home/ken/search/apache-solr-1.3.0/example/webapps/solr.war</Set>

  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>

  <Array id="plusConfig" type="java.lang.String">
    <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
    <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
    <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
  </Array>

  <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>

  <New class="org.mortbay.jetty.plus.naming.EnvEntry">
    <Arg>/solr/home</Arg>
    <Arg type="java.lang.String">/home/ken/search/apache-solr-1.3.0/example/solr</Arg>
    <Arg type="java.lang.Boolean">true</Arg>
  </New>

</Configure>

last edited 2009-02-04 01:31:17 by HossMan