如何修复Solr异常:找不到必要的SLF4j日志记录罐?

时间:2013-05-07 09:44:17

标签: tomcat solr tomcat6 solr4

我在Ubuntu 12.04下安装Solr 4.3时遇到大问题。首先我安装了tomcat。我可以通过localhost:8080上的浏览器访问tomcat。进入“Tomcat Web应用程序管理器”我尝试通过2solr.war“文件安装Solr 4.3。该文件已上传部署。但我无法启动它。”失败 - 上下文路径/ solr的应用程序无法启动“。

日志文件(localhost.log)如下所示:

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

卡塔利娜.....日志

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

有人可以帮助我并告诉我该怎么做吗?

3 个答案:

答案 0 :(得分:29)

正如日志所说 - Could not find necessary SLF4j logging jars.

你错过了slf4j罐子。

slf4j个jar放在$CATALINA_BASE/lib文件夹中。有关详细信息,请查看here

答案 1 :(得分:1)

如果您不想复制内容,可以修改CLASSPATH变量,以包含所有相关内容。

这是你可以做的一个例子:

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'`"

这会给你类似的东西:

# 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

您可以在tomcat的/ etc / default / tomcat7(或RHEL发行版/etc/tomcat7/tomcat7.conf)中设置变量CLASSPATH。所以,当tomcat启动时,你会在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]

我认为设置变量是更清洁的方式来维护你的系统然后复制东西。

如果你愿意,你可以从slf4j包中使用libs(检查它们在哪里安装了dpkg -L libslf4j-java / rpm -ql slf4j,并从/ usr / share / java中获取jar)。您还可以使用系统工具(apt-get / yum)升级slf4j(以及通过CLASSPATH变量“包含”的其他库)。

希望这有帮助。

PS。如果您使用Debian / Ubuntu,还有一个额外的步骤 - 您必须修改您的JAVA_OPTS以包含:

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

为此工作。似乎Debian / Ubuntu没有配置变量CLASSPATH作为基于RHEL的发行版。

答案 2 :(得分:1)

您需要完成这些消息在日志文件中所说的内容:

  

SLF4j日志记录罐从<solr>/example/lib/ext/*.jar复制到Tomcat Lib(例如TOMCAT_HOME/lib/usr/share/tomcat/lib)或Webapp Lib目录(例如TOMCAT_HOME/webapps/solr/WEB-INF/lib)。这些广告罐将设置SLF4Jlog4j

     

如果使用Jetty,SLF4j日志记录罐需要进入jetty lib / ext目录。对于其他容器,应使用相应的目录。有关详细信息,请参阅:http://wiki.apache.org/solr/SolrLogging

换句话说,要使您的Solr与Tomcat一起正常工作,您需要:

  1. 将SLF4j日志记录罐从<solr>/example/lib/ext/*.jar复制到Tomcat Lib(例如TOMCAT_HOME/lib/usr/share/tomcat/lib)或Webapp Lib目录(例如TOMCAT_HOME/webapps/solr/WEB-INF/lib)。这些罐子将设置SLF4J和log4j。

    对于使用操作系统供应商提供的Tomcat软件包的Debian或Ubuntu服务器,可能是/usr/share/tomcat6/lib/usr/share/tomcat7/lib

    例如:

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

    或:

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

    或者设置CLASSPATH以指向您的jar文件。

  2. 将日志配置从solr/example/resources/log4j.properties复制到类路径上的某个位置。通常,您可以使用与上面jar文件相同的位置,并编辑首选日志目标的配置文件。

    或者,如果您未在类路径上放置log4j.properties,请设置java选项: -Dlog4j.configuration=file:///path/to/log4j.properties

  3. 重启Tomcat(例如sudo /etc/init.d/tomcat7 restart)。

  4. 如果您仍然遇到问题,可以使用-Dlog4j.debug=true启动服务器以查看更多详细信息。

    请参阅:Using the example logging setup in containers other than Jetty