Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 415
Stillmatic1985 Avatar asked May 07 '13 09:05

Stillmatic1985


2 Answers

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

like image 76
JHS Avatar answered Oct 05 '22 02:10

JHS


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.

like image 30
Jakov Sosic Avatar answered Oct 05 '22 02:10

Jakov Sosic