Maven 项目:带有 slf4j 和 logback 日志记录的 SolrJ 导致 SolrException:加载错误 class 'org.slf4j.Logger;org.slf4j.Logger'

Maven project: SolrJ with slf4j and logback logging causes SolrException: Error loading class 'org.slf4j.Logger;org.slf4j.Logger'

我有以下设置:一个 Spring 应用程序,它使用 SolrJ 和 slf4j 通过 logback 进行日志记录。当我在 tomcat 服务器上启动应用程序时,出现以下错误。因此,SolrJ 以某种方式找不到 slf4j 日志记录组件,但我验证了相应的 .jar 文件实际上位于我 WAR.

的正确 lib 文件夹中
2017-05-12 09:37:54,094 WARN  [org.apache.solr.common.SolrException: Error loading class 'org.slf4j.Logger;org.slf4j.Logger'
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:556)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:625)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:590)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:583)
    at org.apache.solr.logging.LogWatcher.createWatcher(LogWatcher.java:181)
    at org.apache.solr.logging.LogWatcher.newRegisteredLogWatcher(LogWatcher.java:134)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:473)
    at de.imi.MDMJava.config.AppConfig.solrClient(AppConfig.java:259)
    at de.imi.MDMJava.config.AppConfig$$EnhancerBySpringCGLIB$$ece8fb2.CGLIB$solrClient(<generated>)
    at de.imi.MDMJava.config.AppConfig$$EnhancerBySpringCGLIB$$ece8fb2$$FastClassBySpringCGLIB$23340f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at de.imi.MDMJava.config.AppConfig$$EnhancerBySpringCGLIB$$ece8fb2.solrClient(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4810)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1692)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:465)
    at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:415)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    at javax.management.remote.rmi.RMIConnectionImpl.access0(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport.run(Transport.java:200)
    at sun.rmi.transport.Transport.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run[=12=](TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org/slf4j/Logger;org/slf4j/Logger
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:540)
    ... 103 common frames omitted
] in LogWatcher.java:createWatcher:184: Unable to load LogWatcher org.slf4j.Logger;org.slf4j.Logger: {}
2017-05-12 09:37:55,991 WARN  [] in WebSecurity.java:performBuild:300: 

我的 pom.xml 登录部分如下所示:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.2.3</version>
    </dependency>

Maven 依赖树如下所示:

$ mvn dependency:tree -Dverbose | grep slf4j
[INFO] |  |  \- (org.slf4j:slf4j-api:jar:1.7.21:compile - omitted for conflict with 1.7.7)
[INFO] |  +- (org.slf4j:jcl-over-slf4j:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] |  +- (org.slf4j:jcl-over-slf4j:jar:1.7.7:compile - omitted for duplicate)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for duplicate)
[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)

不幸的是,完整的依赖关系树对于这个 post 来说太长了,但是如果您需要任何进一步的信息,请告诉我。感谢您的任何建议。

编辑 1:

我的 WAR 文件的“/WEB-INF/lib/”目录中有一个 "slf4j-api-1.7.25.jar" 文件,其中包含所有库。

完整的 Maven 依赖树,我去掉了不包含 "slf4j":

的部分
[more dependencies, but no occurence of slf4j...]
[INFO] +- org.springframework.security:spring-security-ldap:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework.ldap:spring-ldap-core:jar:2.2.0.RELEASE:compile
[INFO] |  |  \- (org.slf4j:slf4j-api:jar:1.7.21:compile - omitted for conflict with 1.7.7)
[INFO] |  +- (org.springframework.security:spring-security-core:jar:4.2.2.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-beans:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  \- (org.springframework:spring-tx:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] +- org.springframework.security:spring-security-openid:jar:4.2.2.RELEASE:compile
[INFO] |  +- com.google.inject:guice:jar:2.0:compile
[INFO] |  |  \- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] |  +- org.openid4java:openid4java-nodeps:jar:0.9.6:compile
[INFO] |  |  \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] |  +- (org.springframework.security:spring-security-core:jar:4.2.2.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework.security:spring-security-web:jar:4.2.2.RELEASE:compile - omitted for duplicate)
[INFO] |  +- (org.springframework:spring-aop:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-beans:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-context:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-core:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- (org.springframework:spring-web:jar:4.3.5.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.20:runtime
[INFO] |  |  \- xerces:xercesImpl:jar:2.10.0:runtime
[INFO] |  |     \- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for conflict with 1.0.b2)
[INFO] |  \- (org.apache.httpcomponents:httpclient:jar:4.2.3:compile - scope updated from runtime; omitted for duplicate)
[INFO] +- org.apache.solr:solr-core:jar:6.5.1:compile
[more dependencies, but no occurence of slf4j...]
[INFO] |  +- org.restlet.jee:org.restlet:jar:2.3.0:compile
[INFO] |  +- org.restlet.jee:org.restlet.ext.servlet:jar:2.3.0:compile
[INFO] |  +- (org.slf4j:jcl-over-slf4j:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] +- org.apache.solr:solr-solrj:jar:6.5.1:compile
[INFO] |  +- (commons-io:commons-io:jar:2.5:compile - omitted for duplicate)
[INFO] |  +- (org.apache.httpcomponents:httpclient:jar:4.4.1:compile - omitted for conflict with 4.2.3)
[INFO] |  +- (org.apache.httpcomponents:httpcore:jar:4.4.1:compile - omitted for duplicate)
[INFO] |  +- (org.apache.httpcomponents:httpmime:jar:4.4.1:compile - omitted for duplicate)
[INFO] |  +- (org.apache.zookeeper:zookeeper:jar:3.4.6:compile - omitted for duplicate)
[INFO] |  +- (org.codehaus.woodstox:stax2-api:jar:3.1.4:compile - omitted for duplicate)
[INFO] |  +- (org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:compile - omitted for duplicate)
[INFO] |  +- (org.noggit:noggit:jar:0.6:compile - omitted for duplicate)
[INFO] |  +- (org.slf4j:jcl-over-slf4j:jar:1.7.7:compile - omitted for duplicate)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for duplicate)
[INFO] +- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  +- (ch.qos.logback:logback-core:jar:1.2.3:compile - omitted for duplicate)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.8.8:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.8:compile
[INFO] |  +- (com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile - omitted for conflict with 2.5.4)
[INFO] |  \- (com.fasterxml.jackson.core:jackson-core:jar:2.8.8:compile - omitted for duplicate)
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.8:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  +- (org.apache.httpcomponents:httpcore:jar:4.4.4:compile - omitted for conflict with 4.4.1)
[INFO] |  \- (commons-codec:commons-codec:jar:1.9:compile - omitted for conflict with 1.10)
[INFO] +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] +- org.jdom:jdom:jar:1.1:compile
[INFO] +- javax.servlet:jstl:jar:1.2:compile
[INFO] +- org.apache.tiles:tiles-extras:jar:3.0.5:compile
[INFO] |  +- org.apache.tiles:tiles-core:jar:3.0.5:compile
[INFO] |  |  +- org.apache.tiles:tiles-api:jar:3.0.5:compile
[INFO] |  |  |  \- (org.apache.tiles:tiles-request-api:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  |  \- commons-digester:commons-digester:jar:2.0:compile
[INFO] |  |     \- commons-beanutils:commons-beanutils:jar:1.8.0:compile
[INFO] |  +- org.apache.tiles:tiles-request-servlet-wildcard:jar:1.0.6:compile
[INFO] |  |  +- org.apache.tiles:tiles-request-servlet:jar:1.0.6:compile
[INFO] |  |  |  \- (org.apache.tiles:tiles-request-api:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  |  \- (org.springframework:spring-web:jar:3.2.0.RELEASE:compile - omitted for conflict with 4.3.7.RELEASE)
[INFO] |  +- org.apache.tiles:tiles-request-mustache:jar:1.0.6:compile
[INFO] |  |  +- org.apache.tiles:tiles-request-api:jar:1.0.6:compile
[INFO] |  |  \- com.github.spullara.mustache.java:compiler:jar:0.8.4:compile
[INFO] |  |     \- (com.google.guava:guava:jar:12.0:compile - omitted for conflict with 14.0.1)
[INFO] |  +- org.apache.tiles:tiles-jsp:jar:3.0.5:compile
[INFO] |  |  +- org.apache.tiles:tiles-servlet:jar:3.0.5:compile
[INFO] |  |  |  +- (org.apache.tiles:tiles-core:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  |  \- (org.apache.tiles:tiles-request-servlet:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  |  +- org.apache.tiles:tiles-template:jar:3.0.5:compile
[INFO] |  |  |  +- (org.apache.tiles:tiles-api:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  |  \- org.apache.tiles:tiles-autotag-core-runtime:jar:1.1.0:compile
[INFO] |  |  \- org.apache.tiles:tiles-request-jsp:jar:1.0.6:compile
[INFO] |  |     +- (org.apache.tiles:tiles-request-api:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  |     \- (org.apache.tiles:tiles-request-servlet:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  +- org.apache.tiles:tiles-freemarker:jar:3.0.5:compile
[INFO] |  |  +- (org.apache.tiles:tiles-servlet:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  +- (org.apache.tiles:tiles-template:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  \- org.apache.tiles:tiles-request-freemarker:jar:1.0.6:compile
[INFO] |  |     +- (org.apache.tiles:tiles-request-api:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  |     +- org.freemarker:freemarker:jar:2.3.15:compile
[INFO] |  |     \- (org.apache.tiles:tiles-request-servlet:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  +- org.apache.tiles:tiles-velocity:jar:3.0.5:compile
[INFO] |  |  +- (org.apache.tiles:tiles-servlet:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  +- (org.apache.tiles:tiles-template:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  +- org.apache.velocity:velocity-tools:jar:2.0:compile
[INFO] |  |  |  +- (commons-collections:commons-collections:jar:3.2:compile - omitted for conflict with 3.2.2)
[INFO] |  |  |  +- oro:oro:jar:2.0.8:compile
[INFO] |  |  |  \- org.apache.velocity:velocity:jar:1.6.2:compile
[INFO] |  |  |     +- (commons-collections:commons-collections:jar:3.2.1:compile - omitted for conflict with 3.2.2)
[INFO] |  |  |     +- (commons-lang:commons-lang:jar:2.4:compile - omitted for conflict with 2.6)
[INFO] |  |  |     \- (oro:oro:jar:2.0.8:compile - omitted for duplicate)
[INFO] |  |  +- (commons-digester:commons-digester:jar:2.0:compile - omitted for duplicate)
[INFO] |  |  \- org.apache.tiles:tiles-request-velocity:jar:1.0.6:compile
[INFO] |  |     +- (org.apache.velocity:velocity-tools:jar:2.0:compile - omitted for duplicate)
[INFO] |  |     \- (org.apache.tiles:tiles-request-servlet:jar:1.0.6:compile - omitted for duplicate)
[INFO] |  +- org.apache.tiles:tiles-el:jar:3.0.5:compile
[INFO] |  |  \- (org.apache.tiles:tiles-core:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  +- org.apache.tiles:tiles-mvel:jar:3.0.5:compile
[INFO] |  |  +- (org.apache.tiles:tiles-core:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  \- org.mvel:mvel2:jar:2.0.11:compile
[INFO] |  +- org.apache.tiles:tiles-ognl:jar:3.0.5:compile
[INFO] |  |  +- (org.apache.tiles:tiles-core:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  \- ognl:ognl:jar:2.7.3:compile
[INFO] |  |     \- jboss:javassist:jar:3.7.ga:compile
[INFO] |  +- org.apache.tiles:tiles-compat:jar:3.0.5:compile
[INFO] |  |  +- (org.apache.tiles:tiles-core:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  |  \- (org.apache.tiles:tiles-jsp:jar:3.0.5:compile - omitted for duplicate)
[INFO] |  \- (com.google.guava:guava:jar:12.0.1:compile - omitted for conflict with 14.0.1)
[INFO] +- javax:javaee-web-api:jar:7.0:provided
[INFO] +- org.projectlombok:lombok:jar:1.16.10:provided
[INFO] +- junit:junit:jar:4.12:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.2:provided
[INFO] +- javax.mail:mail:jar:1.4.7:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- cglib:cglib:jar:2.2.2:compile
[INFO] |  \- asm:asm:jar:3.3.1:compile
[INFO] +- org.webjars:jquery:jar:3.2.0:compile
[INFO] +- org.webjars:bootstrap:jar:3.3.7:compile
[INFO] |  \- (org.webjars:jquery:jar:1.11.1:compile - omitted for conflict with 3.2.0)
[INFO] +- org.webjars.bower:devbridge-autocomplete:jar:1.3.0:compile
[INFO] |  \- org.webjars.bower:jquery:jar:3.2.1:compile
[INFO] +- org.webjars:webjars-locator:jar:0.32:compile
[INFO] |  +- org.webjars:webjars-locator-core:jar:0.30:compile
[INFO] |  |  +- (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] |  |  +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] |  |  \- org.apache.commons:commons-compress:jar:1.9:compile
[INFO] |  \- (com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile - omitted for conflict with 2.8.8)
[INFO] \- com.github.dpaukov:combinatoricslib3:jar:3.1.1:compile

编辑 2:

这里是WAR包中slf4j-api-1.7.25.jar的内容。 "org/slf4j/Logger.class" 似乎存在。当我部署 webapp 时,slf4j-api-1.7.25.jar 拥有 644 权限,我的用户是该文件的所有者。这会导致问题吗?

slf4j-api-1.7.25
├── META-INF
│   ├── MANIFEST.MF
│   └── maven
│       └── org.slf4j
│           └── slf4j-api
│               ├── pom.properties
│               └── pom.xml
└── org
    └── slf4j
        ├── event
        │   ├── EventConstants.class
        │   ├── EventRecodingLogger.class
        │   ├── Level.class
        │   ├── LoggingEvent.class
        │   └── SubstituteLoggingEvent.class
        ├── helpers
        │   ├── BasicMarker.class
        │   ├── BasicMarkerFactory.class
        │   ├── BasicMDCAdapter.class
        │   ├── BasicMDCAdapter.class
        │   ├── FormattingTuple.class
        │   ├── MarkerIgnoringBase.class
        │   ├── MessageFormatter.class
        │   ├── NamedLoggerBase.class
        │   ├── NOPLogger.class
        │   ├── NOPLoggerFactory.class
        │   ├── NOPMDCAdapter.class
        │   ├── SubstituteLogger.class
        │   ├── SubstituteLoggerFactory.class
        │   ├── Util.class
        │   ├── Util.class
        │   └── Util$ClassContextSecurityManager.class
        ├── ILoggerFactory.class
        ├── IMarkerFactory.class
        ├── Logger.class
        ├── LoggerFactory.class
        ├── Marker.class
        ├── MarkerFactory.class
        ├── MDC.class
        ├── MDC.class
        ├── MDC$MDCCloseable.class
        └── spi
            ├── LocationAwareLogger.class
            ├── LoggerFactoryBinder.class
            ├── MarkerFactoryBinder.class
            └── MDCAdapter.class

编辑 3: @AlexC 你是对的。我搜索了“.Logger;”并在我的 solr.xml:

中找到了这一行
<str name="class">${loggingClass:org.slf4j.Logger;org.slf4j.Logger}</str>

我改成了:

<logging>
    <str name="class">${loggingClass:org.slf4j.Logger}</str>
    <str name="enabled">${loggingEnabled:true}</str>
    <watcher>
      <int name="size">${loggingSize:50}</int>
      <str name="threshold">${loggingThreshold:WARN}</str>
    </watcher>
  </logging>

仍然是相同的错误,但现在使用 "org.slf4j.Logger" 代替(使用 jcl-over-slf4j、logback-core 和不使用):

2017-05-12 14:33:16,411 WARN  [java.lang.ClassCastException: interface org.slf4j.Logger
    at java.lang.Class.asSubclass(Class.java:3404)
    at org.apache.solr.core.SolrResourceLoader.findClass(SolrResourceLoader.java:540)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:625)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:590)
    at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:583)
    at org.apache.solr.logging.LogWatcher.createWatcher(LogWatcher.java:181)
    at org.apache.solr.logging.LogWatcher.newRegisteredLogWatcher(LogWatcher.java:134)
    at org.apache.solr.core.CoreContainer.load(CoreContainer.java:473)
    [...]
    at java.lang.Thread.run(Thread.java:745)
] in LogWatcher.java:createWatcher:184: Unable to load LogWatcher org.slf4j.Logger: {}

编辑 4:

也许可以通过我的以下评论为大家澄清这一点:"Solr is integrated into my application via SolrJ. I do not run a separate Solr instance. I know this should only be done for debugging purpose but my usage of Solr does not justify a standalone Solr server."

我试图通过 pom.xml 中的排除项删除 slf4j 的所有依赖项。现在唯一剩下的依赖项是:

[INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  +- (ch.qos.logback:logback-core:jar:1.2.3:compile - omitted for duplicate)
[INFO] |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
[INFO] +- ch.qos.logback:logback-core:jar:1.2.3:compile

我找到了我的设置的解决方法。首先,由于以下句子,我将所有类型的连接器添加到 slf4j 登录到我的 pom.xml 在 Solr wiki.

If you use an entirely different logging mechanism like logback, then you must have intercepts for all three - JUL, JCL, and log4j.

此外,我在 class LogWatcher.java 第 184 行中找到了导致我的日志记录问题的 Solr 代码(另请参阅我的问题中的异常消息)。以下是 Github.

中的代码摘录
  private static LogWatcher createWatcher(LogWatcherConfig config, SolrResourceLoader loader) {

    String fname = config.getLoggingClass();
    String slf4jImpl;

    try {
      slf4jImpl = StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr();
      log.debug("SLF4J impl is " + slf4jImpl);
      if (fname == null) {
        if ("org.slf4j.impl.Log4jLoggerFactory".equals(slf4jImpl)) {
          fname = "Log4j";
        } else if (slf4jImpl.indexOf("JDK") > 0) {
          fname = "JUL";
        }
      }
    }
    catch (Throwable e) {
      log.warn("Unable to read SLF4J version.  LogWatcher will be disabled: " + e);
      if (e instanceof OutOfMemoryError) {
        throw (OutOfMemoryError) e;
      }
      return null;
    }

    if (fname == null) {
      log.debug("No LogWatcher configured");
      return null;
    }

    if ("JUL".equalsIgnoreCase(fname))
      return new JulWatcher(slf4jImpl);
    if ("Log4j".equals(fname))
      return new Log4jWatcher(slf4jImpl);

    try {
      return loader != null ? loader.newInstance(fname, LogWatcher.class) : null;
    }
    catch (Throwable e) {
      log.warn("Unable to load LogWatcher {}: {}", fname, e);
      if (e instanceof OutOfMemoryError) {
        throw (OutOfMemoryError) e;
      }
    }

    return null;
  }
}

有问题的部分是最后一个 try/catch 块,所以 fname == "org.slf4j.Logger" 似乎无效。但是,正如我们在代码顶部看到的那样,如果 fname == null,则字符串 "Log4j" 用作回退。因此,我只是决定在我的 solr 日志记录配置中使用 "Log4j"(如下所示)并让 log4j-over-slf4j 连接器处理与 slf4j 的连接。

<solr>

    ...

    <logging>
        <str name="class">Log4j</str>
        <bool name="enabled">true</bool>
        <!-- default watcher param -->
        <watcher>
            <int name="size">50</int>
            <str name="threshold">FINEST</str>
        </watcher>
    </logging>

    ...

</solr>

我想这不是完美的解决方案,但对我来说这似乎是一个足够好的解决方案。