Solr and Tomcat

Solr and Tomcat are two great tastes that go great together. This is especially true when you can enter http://solr in your browser or when working with your collection at the command line. We're going for something like this.

There are many guides on configuring Solr with Tomcat, many of which miss an important component, the Solr application logging JARs. Let's cover that first.

While I was initially configuring Solr with Tomcat, I knew everything was correct.  And everything WAS configured correctly, yet I was still not seeing Solr Admin in Tomcat. Finally it dawned on me to check the Tomcat localhost logs where I discovered Solr was missing something.

Here are the JARs you'll need to add to Tomcat lib.

Now that we covered the logging JARs you can go back to Tomcat and fire up Solr! Well, almost.

Prepping Solr

Most guides advocate duplicating your Solr example/ area. You don't have to, but it's a good idea to start fresh with just the Solr configuration you need. I created a home/ folder on the same level as Solr/example. Since I used Jetty with Solr to poke around and play before moving to Tomcat, I copied the expanded Solr.war to Solr/home/webapp. I then copied the Solr/example/solr area and removed everything but the essentials for my core collections. Here's my Solr home folder.

Adding Solr Tomcat Site

We'll add the Solr site with a solr.xml context file in the Tomcat localhost folder. (conf/Catalina/localhost/solr.xml.)

You can see we're pointing to the Solr/home/webapp as our docBase and defining our Solr Collection home location in the Tomcat context file.


We want to make some Java properties available to Solr in Tomcat, so we'll place them in /etc/profile. We'll be adding the last 3 lines. Remember to load them with ” $ . /etc/profile” at the command line.


One of the main purposes of this exercise is to use a sweet url for local development purposes, how 'bout http://solr? To do so we need the Apache proxy_httpd module and create a virtual host.  I blogged about that a few months ago here.

Here's our Apache2 sites-available Solr.conf file. The only thing to point out here is…well, nothing. Nothing different here than any other Tomcat Apache Site Config with proxy_httpd.

Loading the Solr Admin Dashboard

The only thing yet to address is that Jetty always assumed we would use a context path with /solr in it like http://localhost:8983/solr.  We're not, so we need to make a small change to our /webapp/admin.html file.

There are probably other/better ways to change the ${contextPath}, but none of the 58 ways I tried seemed to work. Changing the app_config.solr_path in admin.html as shown below works just fine.

http://solr Revisited

And there we are. http://solr!

Posted April 04, 2014 04:41 PM EDT

More Like This Post