SpringMvc+Mybatis整合hbase時出現的問題
阿新 • • 發佈:2019-01-26
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:2108)
at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2001)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:1918)
at org.apache.hadoop.conf.Configuration.get(Configuration.java:721)
at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:740)
at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1093)
at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:66)
at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:102)
at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:113)
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:2108)
at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2001)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:1918)
at org.apache.hadoop.conf.Configuration.get(Configuration.java:721)
at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:740)
at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1093)
at org.apache.hadoop.hbase.HBaseConfiguration.checkDefaultsVersion(HBaseConfiguration.java:66)
at org.apache.hadoop.hbase.HBaseConfiguration.addHbaseResources(HBaseConfiguration.java:102)
at org.apache.hadoop.hbase.HBaseConfiguration.create(HBaseConfiguration.java:113)
at com.yitian.zhishang.utils.HbaseOperatorUtil.<clinit>(HbaseOperatorUtil.java:33)
以上錯誤是由於javaee6中的webservices-api-osgi.jar 和 guava12.0.1.jar(使用hbase需要用到的jar包)產生的衝突;
注意:這個錯誤是直接執行java程式引起的
解決的辦法有如下幾個方法:
1、在buildPath中刪除對javaee6的引用
2、使用javaee5來代替javaee6
3、採用servlet來呼叫對hbase的操作(採用的是tomcat伺服器)
產生以上錯誤的原因是jar包的載入順序引起的:
(1)如果是直接執行一個java檔案,jar包是先載入javaee6的,然後再載入使用者自己新增進去的jar包
(2)如果是採用tomcat,則tomcat是先載入使用者匯入的jar包,然後再載入javaee的
注意:
在tomcat中,jar包的載入順便可以自己在context.xml檔案設定<Loader delegate="true" />