请先关注 [低调大师] 公众号 优秀的自媒体个人博客,低调大师,许军

低调大师

您现在的位置是:首页>文章详情

文章详情

NoClassDefFoundError: org/slf4j/LoggerFactory和NoClassDefFoundError: or...

2017-12-26 179热度

1.如果运行程序出现错误:“Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory”,这是因为项目缺少slf4j-api.jar和slf4j-log4j12.jar这两个jar包导致的错误。

2.如果运行程序出现错误:“java.lang.NoClassDefFoundError: org/apache/log4j/LogManager”,这是因为项目缺少log4j.jar这个jar包

3.错误:“Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.MDC.getCopyOfContextMap()Ljava/util/Map”,这是因为jar包版本冲突造成的。

slf4j-log4j12.jar版本信息:

复制代码
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: ceki
Build-Jdk: 1.5.0_06
Bundle-Description: The slf4j log4j-12 binding
Bundle-Version: 1.3.1
Implementation-Version: 1.4.2
Implementation-Title: slf4j-log4j12
Bundle-ManifestVersion: 2
Bundle-SymbolicName: slf4j.log4j12
Bundle-Name: slf4j-log4j12
Bundle-Vendor: SLF4J.ORG
Export-Package: org.slf4j.impl;version=1.3.1
Import-Package: org.slf4j;version="[1.3,1.4)", org.slf4j.spi;version="
[1.3,1.4)", org.slf4j.helpers;version="[1.3,1.4)", org.apache.log4j
复制代码

slf4j-api.jar版本信息:

复制代码
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: ceki
Build-Jdk: 1.5.0_06
Bundle-Description: The slf4j API
Bundle-Version: 1.3.1
Implementation-Version: 1.4.2
Implementation-Title: slf4j-api
Bundle-ManifestVersion: 2
Bundle-SymbolicName: slf4j.api
Bundle-Name: slf4j-api
Bundle-Vendor: SLF4J.ORG
Export-Package: org.slf4j;version=1.3.1, org.slf4j.spi;version=1.3.1,
org.slf4j.helpers;version=1.3.1
Import-Package: org.slf4j.impl;version="[1.3,1.4)"
复制代码

log4j.jar版本信息:

复制代码
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.3.1_18-b01 (Sun Microsystems Inc.)

Name: org/apache/log4j/
Implementation-Title: log4j
Implementation-Version: 1.2.14
Implementation-Vendor: "Apache Software Foundation"
复制代码

后来将log4j.jar版本从上面的1.2.14换到1.2.11

复制代码
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.4
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)

Name: org/apache/log4j/
Implementation-Title: log4j
Implementation-Version: 1.2.11
Implementation-Vendor: "Apache Software Foundation"
复制代码

就不再出现“Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.MDC.getCopyOfContextMap()Ljava/util/Map”错误了。

4.ActiveMQ错误:Wire format negociation timeout: peer did not send his wire format.

官方解释:http://activemq.apache.org/javaxjmsjmsexception-wire-format-negociation-timeout-peer-did-not-send-his-wire-format.html

我出现这样的错误主要是因为ActiveMQ与slf4j的版本有冲突,我原先使用的是以前一种用的slf4j-1.4。后来看apache-activemq-5.5.1\lib目录下有slf4j-api-1.5.11.jar、slf4j-log4j12-1.5.11.jar和log4j-1.2.14.jar。我想这几个jar应该是和ActiveMQ匹配的,就使用了这三个jar,最终错误解决。



 本文转自xwdreamer博客园博客,原文链接:http://www.cnblogs.com/xwdreamer/archive/2012/02/20/2359595.html,如需转载请自行联系原作者

收藏 (0)

相关文章

    文章评论

    共有0条评论来说两句吧...