gaoyubotaili 2016-10-25
在Myeclipse构建的Java的Web项目里使用hadoop2.5的jar包,去连接Linux系统上的HDFS,做一个数据展示的工程,发生了一个莫名其妙的异常,信息如下:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.MapMaker.keyEquivalence(Lcom/google/common/base/Equivalence;)Lcom/google/common/collect/MapMaker; at com.google.common.collect.Interners$WeakInterner.<init>(Interners.java:68) at com.google.common.collect.Interners$WeakInterner.<init>(Interners.java:66) at com.google.common.collect.Interners.newWeakInterner(Interners.java:63) at org.apache.hadoop.util.StringInterner.<clinit>(StringInterner.java:49) at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2303) at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2195) at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2112) at org.apache.hadoop.conf.Configuration.set(Configuration.java:989) at org.apache.hadoop.conf.Configuration.set(Configuration.java:961) at com.dhgate.hdfs.tools.HDFSTools.<clinit>(HDFSTools.java:22)
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.MapMaker.keyEquivalence(Lcom/google/common/base/Equivalence;)Lcom/google/common/collect/MapMaker; at com.google.common.collect.Interners$WeakInterner.<init>(Interners.java:68) at com.google.common.collect.Interners$WeakInterner.<init>(Interners.java:66) at com.google.common.collect.Interners.newWeakInterner(Interners.java:63) at org.apache.hadoop.util.StringInterner.<clinit>(StringInterner.java:49) at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2303) at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2195) at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2112) at org.apache.hadoop.conf.Configuration.set(Configuration.java:989) at org.apache.hadoop.conf.Configuration.set(Configuration.java:961) at com.dhgate.hdfs.tools.HDFSTools.<clinit>(HDFSTools.java:22)
开始,散仙以为是guava的包有问题,然后就把guava的包给换了另外一个版本的,然后继续测试,发现依然报这个异常,然后在google上搜索查找,终于发现有个朋友在Hbase的Web项目里,也遇到了类似的异常,而原因大概是因为和项目里的JAVA EE6的Libraries包冲突,具体原因还未查明,后来尝试把JAVA EE6的包给删了,再次运行,则正常运行,或者把JAVA EE6的libraries包换成JAVA EE5的libraries也可正常通过。