Solr with Jetty
Solr runs fine with
Jetty, as illustrated by the solr/example application. See the instructions in the generic Solr installation page for basic setup info For non-trivial installations,
JettyPlus is recommended.
Logging
For information about controlling JDK Logging (aka: java.util logging) in Jetty please consult the Jetty docs...
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:
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:
Specify "ContextDeployer" in jetty.xml
For each web app, add a .xml file in "./contexts"
Set ConfigurationClasses to activate JNDI. (must be done separately for each webapp)
Set overrideDescriptor to define an
override web.xml file In the overrideDescriptor file, set an <env-entry> for "solr/home"
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