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)

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.


(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

last edited 2008-03-22 01:25:19 by HossMan