How to fix Solr Exception: Could not find necessary SLF4j logging jars?
Asked Answered
K

3

17

I have big problems installing Solr 4.3 under Ubuntu 12.04. Firstly i installed tomcat. I can access tomcat via browser on localhost:8080. Into "Tomcat Web Application Manager" i try to install Solr 4.3 via 2solr.war" file. The file is been uploaded an deployed. But i cant get it started. "FAIL - Application at context path /solr could not be started".

The log file (localhost.log) look like:

07.05.2013 11:05:36 org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: start: Starting web application at '/solr'
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext filterStart
SCHWERWIEGEND: Exception starting filter SolrRequestFilter
org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
    at org.apache.solr.servlet.SolrDispatchFilter.<init>(SolrDispatchFilter.java:105)
    ... 33 more
07.05.2013 11:05:36 org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext filterStart
SCHWERWIEGEND: Exception starting filter SolrRequestFilter
org.apache.solr.common.SolrException: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
    at org.apache.solr.servlet.SolrDispatchFilter.<init>(SolrDispatchFilter.java:105)
    ... 21 more

catalina.....log

07.05.2013 11:05:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error filterStart
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context [/solr] startup failed due to previous errors
07.05.2013 11:05:36 org.apache.catalina.startup.HostConfig checkResources
INFO: Reloading context [/solr]
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/solr] has not been started
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error filterStart
07.05.2013 11:05:36 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context [/solr] startup failed due to previous errors

Can somebody help me and tell me what to do?

Krasnoyarsk answered 7/5, 2013 at 9:44 Comment(0)
G
29

As the logs say - Could not find necessary SLF4j logging jars.

You are missing the slf4j jars.

Place the slf4j jars in the $CATALINA_BASE/lib folder. For more information have a look here

Gossipmonger answered 7/5, 2013 at 9:48 Comment(5)
More specifically, wiki.apache.org/solr/SolrLogging: To get the same logging setup in e.g. Tomcat as with the example Jetty server, you need to do the following: 1. Copy the jars from solr/example/lib/ext into tomcat/lib to setup SLF4J 2. Copy the logging config from solr/example/resources/log4j.properties into some location, e.g. tomcat/lib and edit the file for you preferred log destination 3. Optionally, if you did not place log4j.properties on the classpath, set java option -Dlog4j.configuration=file:///path/to/log4j.propertiesPatric
Solr distributes corresponding jar files under dist/solrj-lib/. Just copy them: cp dist/solrj-lib/* /var/lib/tomcat7/lib (make "/lib" if no exists)Grisons
This works, thanks. However, I wonder is there a better way to do this other than copying these files to lib directory. For example can I change a config file so that tomcat will now where to find them?Sil
@capy Worked like a charm. You should submit as an alternative/followup answer.Fermin
You don't need to copy jars, you can point to them in conf/catalina.properties.Feat
B
1

If you don't want to copy stuff around, you can modify your CLASSPATH variable, to include all the relevant stuff.

This is an example what you can do:

cd /tmp
wget http://www.slf4j.org/dist/slf4j-1.6.6.zip
unzip slf4j-1.6.6.zip
mv slf4j-1.6.6/integration/lib slf4j
CLASSPATH="`find /tmp/slf4j/ -type f  | xargs echo | sed 's/ /:/g'`"

That will give you something like:

# echo $CLASSPATH
/tmp/slf4j/slf4j-api-1.6.99.jar:/tmp/slf4j/slf4j-simple-1.6.99.jar:/tmp/slf4j/slf4j-simple-1.5.11.jar:/tmp/slf4j/slf4j-simple-1.4.2.jar:/tmp/slf4j/slf4j-api-1.5.11.jar:/tmp/slf4j/slf4j-simple-1.5.4-SNAPSHOT.jar:/tmp/slf4j/slf4j-nop-1.5.6.jar:/tmp/slf4j/slf4j-1.6.6.zip:/tmp/slf4j/slf4j-simple-1.5.0.jar:/tmp/slf4j/slf4j-api-2.0.99.jar

You can set variable CLASSPATH in your tomcat's /etc/default/tomcat7 (or on RHEL distros /etc/tomcat7/tomcat7.conf). So, when tomcat starts, you will see something like this in catalina.out:

SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-nop-1.5.6.jar!/org/slf4j impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-simple-1.4.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-simple-1.5.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-simple-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-simple-1.5.4-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/slf4j/slf4j-simple-1.6.99.jar!/org/slf4j/impl/StaticLoggerBinder.class]

I think setting up variable is much cleaner way to maintain your system then copying stuff around.

If you want, you can offcourse use the libs from slf4j package (check where are they installed with dpkg -L libslf4j-java / rpm -ql slf4j, and take jars from /usr/share/java). You will also have benefit of being able to upgrade your slf4j (and other libs you "include" via CLASSPATH variable) with system tools (apt-get/yum).

Hope this helps.

PS. If you use Debian/Ubuntu, there's an additional step - you have to modify your JAVA_OPTS to contain:

JAVA_OPTS="${JAVA_OPTS} -classpath ${CLASSPATH}"

for this to work. It seems Debian/Ubuntu don't have config variable CLASSPATH as RHEL-based distros.

Burseraceous answered 25/8, 2014 at 18:14 Comment(2)
Setting CLASSPATH in /etc/default/tomcat7 has no effect.Feat
Thank you, I've corrected my answer. Hope it works now.Burseraceous
A
1

You need to do exactly what these messages say in your log files:

Copy the SLF4j logging jars from <solr>/example/lib/ext/*.jar into Tomcat Lib (e.g. TOMCAT_HOME/lib, /usr/share/tomcat/lib) or Webapp Lib directory (e.g. TOMCAT_HOME/webapps/solr/WEB-INF/lib). These jars will set up SLF4J and log4j.

If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging

In other words to make your Solr working properly with Tomcat, you need to:

  1. Copy the SLF4j logging jars from <solr>/example/lib/ext/*.jar into Tomcat Lib (e.g. TOMCAT_HOME/lib, /usr/share/tomcat/lib) or Webapp Lib directory (e.g. TOMCAT_HOME/webapps/solr/WEB-INF/lib). These jars will set up SLF4J and log4j.

    For a Debian or Ubuntu server using the Tomcat package available from the OS vendor, this is likely to be /usr/share/tomcat6/lib or /usr/share/tomcat7/lib.

    For example:

    # cp -v /opt/solr-4.10.4/example/lib/ext/*.jar /usr/share/tomcat?/lib/
    

    or:

    # cp -v /opt/solr-4.10.4/example/lib/ext/*.jar /var/lib/tomcat7/webapps/solr/WEB-INF/lib/
    

    Alternatively set-up your CLASSPATH to point to your jar files.

  2. Copy the logging config from solr/example/resources/log4j.properties into a location on the classpath. Usually you can use the same location as the jar files above and edit the configuration file for your preferred log destination.

    Optionally, if you did not place log4j.properties on the classpath, set java option: -Dlog4j.configuration=file:///path/to/log4j.properties

  3. Restart Tomcat (e.g. sudo /etc/init.d/tomcat7 restart).

If you still have the problems, it might help to start the server with -Dlog4j.debug=true to see more details.

See: Using the example logging setup in containers other than Jetty

Acromegaly answered 6/4, 2015 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.