NoClassDefFoundError:org.slf4j.impl.StaticLoggerBinder

时间:2016-11-23 14:23:49

标签: slf4j log4

在Tomcat / lib [Tomcat 7]

中添加了jar
log4j-1.2.15.jar,
log4j-api-2.0-alpha2.jar,
log4j-jcl-2.0-alpha2.jar,
logback-classic-1.1.7.jar,
log4j12-api-2.0-alpha2.jar,
log4j-core-2.0-alpha2.jar,
log4j-over-slf4j-1.7.21.jar,
logback-core-1.1.7.jar

slf4j-api-1.7.21.jar,
slf4j-jcl-1.7.21.jar,
slf4j-log4j12-1.7.21.jar,
slf4j-nop-1.7.21.jar
slf4j-ext-1.7.21.jar,
slf4j-jdk14-1.7.21.jar,
slf4j-migrator-1.7.21.jar,
slf4j-simple-1.7.21.jar

获取错误&导致部署失败

无法实例化SLF4J LoggerFactory 报告的例外:

java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder
        at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
        at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
        at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)
        at org.apache.wink.server.internal.servlet.AbstractRestServlet.<clinit>(AbstractRestServlet.java:34)
        at java.lang.J9VMInternals.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1894)
        at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:114)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1146)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1085)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5349)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5641)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
        at java.util.concurrent.FutureTask.run(FutureTask.java:277)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.lang.Thread.run(Thread.java:785)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
        at java.net.URLClassLoader.findClass(URLClassLoader.java:607)
        at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:844)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:823)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:803)

不确定我错过了什么。任何人都可以分享如何纠正错误。

此致

1 个答案:

答案 0 :(得分:1)

我有同样的错误,我相信我的解决方案解决了它。我正在使用Maven,所以我在POM文件中添加了一个依赖项,而不是将.jar文件显式添加到构建路径中。

这里是依赖项(最新版本列在下面链接的顶部。在我的情况下,它是1.7.24,所以如果你可以替换#34; $ {的最新版本SLF4J版本}&#34;:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j-version}</version>
    </dependency>

这是https://mvnrepository.com/artifact/org.slf4j/slf4j-api

如果有效,请告诉我。