SOLR with Tomcat 7

The SOLR search engine is a great project, which keeps getting better. Not having installed one for a while, I went through the usual motions of someone with Tomcat 7 running on Debian:

  • Downloaded the 4.6.0 zip onto the laptop.
  • Found the .war file.
  • Opened Tomcat on the server at the management screen and used the ‘deploy’ option to push it onto the server (saves fiddling with permissions on the server).
  • Added in a database from multicore in /examples
  • Told SOLR where it was in it’s web.xml
  • Restarted the servlet.

And at that point it didn’t work – wouldn’t start the servlet. Hmmm. Did the usual stuff, checked things, ran the downloaded .war in the Jetty engine it comes with – worked perfectly. Several hours went past as I explored whether it was my Java 6 or some config mistake. Finally found out the issue – the nice folks at Apache had done clever things with the logging in 4.3+.

According to this post on their site:

These versions do not include any logging jars in the WAR file. They must be provided separately. The Solr example for these versions includes jars (in the jetty lib/ext directory) that set up SLF4J with a binding to the Apache log4j library.

Basically you can’t just drop the .war onto a servlet container of choice and run it, which I’ve got to say seems to me a little against the spirit of the whole .war gig. Now I can see that it’s very clever to have a really flexible, separate logging mechanism, but annoying that you have to get involved with it by default.


So, the fix is?

Well they provide you with the logging jars in  a folder handily named  “solr-4.6.0/example/lib/ext” which you need to copy into the Tomcat /lib.  Next, you need to copy “solr/example/resources/” into the class path e.g. dropped into /lib as well.  Restart the container and you should be good to go.

Now this is fine if you know what you’re doing etc, but what’s wrong with a .war already set up for those who aren’t? Or perhaps, even if you do know, something in the README to let you know you needed to do something extra and a pointer into the wiki?