How to find specific org/slf4j/Logger jar file out of multiple bindings from the apache zip?

非 Y 不嫁゛ 提交于 2019-12-25 08:39:23

问题


I am using Apache PDFBox & POIFSFilesystem which extract text from the pdfs and export into excel but my application is throwing below error ever after adding the apache-log4j-2.8.2-bin jar files.I tried to add org/slf4j/Logger jar files but its still throwing error. may be i could not find exact files..! pls suggest.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger
    at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
    at org.apache.logging.log4j.jcl.LogAdapter.newLogger(LogAdapter.java:34)
    at org.apache.logging.log4j.jcl.LogAdapter.newLogger(LogAdapter.java:30)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:52)
    at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40)
    at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:55)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
    at org.apache.pdfbox.pdmodel.PDDocument.<clinit>(PDDocument.java:80)

After adding SLF4J-1.7.25. I got below error. its more than 9k lines.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/apache-log4j-2.8.2-bin/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-android-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-jcl-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-jdk14-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-nop-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/slf4j-1.7.25/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)

回答1:


java.lang.NoClassDefFoundError

generally means that the jar file is not provided correctly. Download the slf4j jar file from slf4j.org/download and try again. Also, it is always better to use something like Maven to resolve all your dependencies so that these problems can be avoided.



来源:https://stackoverflow.com/questions/44749945/how-to-find-specific-org-slf4j-logger-jar-file-out-of-multiple-bindings-from-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!