1 http://wiki.apache.org/solr/SolrTomcat
2 http://lucene.apache.org/solr/
SOLR Wiki
- Immutable page
- Show changes
- Get info
Solrtomcat
SOLR with Apache Tomcat
SOLR runs fine with tomcat, see the instructions in the generic SOLR installation page for general info before consulting this page.
- SOLR with Apache Tomcat
- Simple example install
- Optional Configuration
- Logging
- Uri charset config
- Using ing SOLR home with JNDI
- Multiple SOLR webapps
- Tomcat on Windows
- Single SOLR app
- Multiple SOLR apps
- External resources
- Troubleshooting errors
Simple example install
People have occasionally reported problems getting SOLR to work with Tomcat -- usually as a result of confusion stemming from the multitudes of ways Tomcat can be installed and configured (particle ly if Tomcat is installed by some package management system designed for the specific OS ).
these steps upgrade strate the minimal possible steps needed to install both Tomcat and SOLR from scratch by relying on the default "SOLR home dir"...
# If you copy this to a shell script, make sure to run dos2unix on it to ensure correct line-endingsmkdir SOLR-tomcatcd SOLR-Tomcat/tomcat_ver = pull into the latest nightly SOLR buildnightly = 'wget-o-http://people.apache.org/builds/lucene/solr/nightly/ | grep '.zip' | SED's /. * \ (solr-20 .. -.. -.. \. zip \). * // \ 1/'| tail-1 'wget unzip apache-atat-$tomcat_ver.zip unzip $ nightlycp APACHE-SOLR-nightly/Dist/apache-solr-nightly.war APACHE-Tomcat-$ tomcat_ver/webapps/SOLR. warcp-r APACHE-SOLR-nightly/example/SOLR. chmod A + x APACHE-Tomcat-$ tomcat_ver/bin /*. /Apache-Tomcat-$ tomcat_ver/bin/startup. shecho "Now browse to http: // localhost: 8080/SOLR/admin/" # note that the startup. sh script is run from the directory containing your SOLR home. /SOLR # Since the SOLR webapp looks for $ CWD/SOLR by default. # You can use JNDI or a system property to configure the SOLR home directory (described below) # If you want to run the startup. SH from a different working directory.
In addition to using the default behavior of relying on the SOLR home being in the current working directory (. /SOLR) You can alternately Add the SOLR. SOLR. home System property to your JVM settings before starting tomcat...
Export java_opts = "$ java_opts-dsolr. SOLR. Home =/My/custom/SOLR/home/DIR /"
... Or use a context file to configure the SOLR home using JNDI (see below)
(Note that the SOLR home directory can't just be a empty folder. if you do that, you may get random cryptic messages from your servlet container and/or SOLR. for an example proper SOLR home directory look at "example/SOLR/" in the SOLR download package .)
Optional configurationlogging
For information about controlling JDK logging (aka: Java. util logging) in Tomcat, please consult the Tomcat docs... http://tomcat.apache.org/tomcat-6.0-doc/logging.html
Uri charset config
If you are goingQuerySOLR using international characters (> 127) using HTTP-GET, you must configure tomcat to conform to the URI standard by accepting percent-encoded UTF-8.
Edit Tomcat's CONF/server. xml and add the following attribute to the correct connector element: uriencoding = "UTF-8 ".
<Server...> <service...> <connector... uriencoding = "UTF-8"/>... </connector> </service> </Server>
This is only an issue when sending non-ASCII characters in a query request... no configuration is needed for SOLR/tomcat to return non-ASCII chars in a response, or accept non-ASCII chars in an HTTP-POST body.
Using ing SOLR home with JNDI
A tomcat context fragments can be used to configure the JNDI property needed to specify your SOLR home directory.
Just put a context fragment file under $ catalina_home/CONF/Catalina/localhost that looks something like this...
$ CAT/tomcat55/CONF/Catalina/localhost/SOLR. xml
<Context docbase = "/Some/path/SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value ="/My/SOLR/home "override =" true "/> </context>
A few things to keep in mind:
The "CONF/Catalina/localhost" directory may not exist by default in your installation. You may have to create it.
"/Some/path/SOLR. war "is the absolute path to where ever you want to keep the SOLR war using the appropriate syntax for your operating system. in Tomcat 5.5 and later, the war file must be stored outside of the webapps directory for this to work. otherwise, this entire context element is ignored.
"/My/SOLR/home" shocould be to where you have createed your SOLR home directory, using the appropriate syntax for your operating system.
Prior to Tomcat 5.5, a "path" attribute was required for context elements (starting with 5.5, the path attribute must not be used before t when statically defining a context in server. XML, as it will be inferred from the context fragment filename.
Multiple SOLR webapps
Tomcat context fragments make processing ing multiple SOLR webapps (with JNDI) in a single Tomcat server easy.
Just follow the previous instructions for "sorting ing SOLR home with JNDI" to create a seperate context fragment file under $ catalina_home/CONF/Catalina/localhost for each SOLR webapp you want to run:
$ CAT/tomcat55/CONF/Catalina/localhost/solr1.xml
<Context docbase = "/Some/path/SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value ="/Some/path/solr1home "override =" true "/> </context>
$ CAT/tomcat55/CONF/Catalina/localhost/solr2.xml
<Context docbase = "F:/SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value ="/Some/path/solr2home "override =" true "/> </context>
Don't put anything related to SOLR under the webapps directory.
The SOLR home directories are configured via jndi in the context fragment, and in the examples above will be/Some/path/solr1homeAnd/Some/path/solr2homeThe URLs to the two webapps will beHttp: // host: Port/solr1AndHttp: // host: Port/solr2
Tomcat on Windows Single SOLR app
-
Download and install Tomcat for Windows using the MSI Installer. Install it with the tcnative. dll file. Say you installed it in c: \ Tomcat \
-
Check if Tomcat is installed correctly by going to http: // localhost: 8080/
-
Change the c: \ Tomcat \ conf \ Server. xml file to add the uriencoding connector element as shown above.
Download and unzip the SOLR distribution ZIP file into (say) c: \ temp \ solrzip \
-
Make a directory called SOLR where you intend the application server to function, say c: \ WEB \ SOLR \
-
Copy the contents of the example \ SOLR directory c: \ temp \ solrzip \ example \ SOLR \ to C: \ WEB \ SOLR \
-
Stop the Tomcat Service
-
Copy the * SOLR *. War file from c: \ temp \ solrzip \ Dist \ To the Tomcat webapps directory c: \ Tomcat \ webapps \
-
Rename the * SOLR *. War file SOLR. War
-
Use the system tray icon to configure tomcat to start with the following Java option:-dsolr. SOLR. Home = c: \ WEB \ SOLR
-
Start the Tomcat Service
-
Go to the SOLR admin page to verify that the installation is working. It will be at http: // localhost: 8080/SOLR/admin
Multiple SOLR apps
Download and install Tomcat for Windows using the MSI Installer. Install it with the tcnative. dll file. Say you installed it in c: \ Tomcat \
-
Check if Tomcat is installed correctly by going to http: // localhost: 8080/
-
Change the c: \ Tomcat \ conf \ Server. xml file to add the uriencoding connector element as shown above.
-
Download and unzip the SOLR distribution ZIP file into (say) c: \ temp \ solrzip \
-
Say you need two apps in c: \ WEB \ solr1 and c: \ WEB \ solr2; create these two directories
-
Copy the contents of the example \ SOLR directory c: \ temp \ solrzip \ example \ SOLR \ to C: \ WEB \ solr1 \ and to c: \ WEB \ solr2 \
-
Stop the Tomcat Service
-
Copy the * SOLR *. War file from c: \ temp \ solrzip \ Dist \ To the Tomcat lib directory c: \ Tomcat \ Lib \
Rename the * SOLR *. War file SOLR. War
-
Make a new text file in c: \ Tomcat \ conf \ Catalina \ localhost called solr1.xml with the following code fragment
<Context docbase = "C: \ Tomcat \ Lib \ SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value =" C: \ WEB \ solr1 "override =" true "/> </context>
-
Make a new text file in c: \ Tomcat \ conf \ Catalina \ localhost called solr2.xml with the following code fragment
<Context docbase = "C: \ Tomcat \ Lib \ SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value =" C: \ WEB \ solr2 "override =" true "/> </context>
-
Start the Tomcat Service
Go to the SOLR admin pages for the 2 webapps to verify that the installation is working. it will be at http: // localhost: 8080/solr1/admin and http: // localhost: 8080/solr2/admin
External resources
Http://www.ibm.com/developerworks/java/library/j-solr1/
Troubleshooting errors
It's possible that you get an error related to the following:
severe: exception starting filter solrrequestfilterjava. lang. noclassdeffounderror: cocould not initialize class Org. apache. SOLR. core. solrconfig at Org. apache. SOLR. servlet. solrdispatchfilter. init (solrdispatchfilter. java: 76 )......... caused by: Java. lang. runtimeexception: xpathfactory # newinstance () failed to create an xpathfactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the xpathfactoryconfigurationexception: javax. XML. XPath. xpathfactoryconfigurationexception: No xpathfctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom at javax. XML. XPath. xpathfactory. newinstance (unknown source)
This is due to your Tomcat instance not having the xalan JAR file in the classpath. it took me some digging to find this, and thought it might be useful for others. the location varies from distribution to distribution, But I essentially just added (via a symlink) the JAR file to the shared/lib directory under the Tomcat directory.
Last edited 18:42:38Yonikseeley
- Immutable page
- Show changes
- Get info
- Moinmoin powered
- Python powered
- Valid, HTML 4.01