HBase 1.1.2 + Kryo 4.0.1組合使用沿盅,kryo將數(shù)據(jù)序列化為byte數(shù)組后入到HBase中,查詢程序?qū)Base取出來后纫溃,調(diào)用Kryo反序列化腰涧,突然出現(xiàn)了下面的錯(cuò)誤,出現(xiàn)了jar包版本沖突了
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
at com.esotericsoftware.reflectasm.ConstructorAccess.insertConstructor(ConstructorAccess.java:128)
at com.esotericsoftware.reflectasm.ConstructorAccess.get(ConstructorAccess.java:98)
at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy.newInstantiatorOf(Kryo.java:1271)
at com.esotericsoftware.kryo.Kryo.newInstantiator(Kryo.java:1127)
at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1136)
at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:562)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:538)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813)
at com.yuewen.data.util.KryoUtil.readFromByte(KryoUtil.java:52)
at com.yuewen.data.Query.main(Query.java:37)
通過mvn dependency:tree命令查看依賴樹結(jié)果如下:
[INFO] +- org.apache.hbase:hbase-server:jar:1.1.2:compile
[INFO] | +- org.apache.hbase:hbase-procedure:jar:1.1.2:compile
[INFO] | | \- org.apache.hbase:hbase-common:jar:tests:1.1.2:compile
[INFO] | +- org.apache.hbase:hbase-prefix-tree:jar:1.1.2:runtime
[INFO] | +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | +- org.apache.hbase:hbase-hadoop-compat:jar:1.1.2:compile
[INFO] | +- org.apache.hbase:hbase-hadoop2-compat:jar:1.1.2:compile
[INFO] | +- com.yammer.metrics:metrics-core:jar:2.2.0:compile
[INFO] | +- com.sun.jersey:jersey-core:jar:1.9:compile
[INFO] | +- com.sun.jersey:jersey-server:jar:1.9:compile
[INFO] | | \- asm:asm:jar:3.1:compile
[INFO] | +- commons-cli:commons-cli:jar:1.2:compile
[INFO] | +- org.apache.commons:commons-math:jar:2.2:compile
[INFO] | +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] | +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] | +- org.mortbay.jetty:jetty-sslengine:jar:6.1.26:compile
[INFO] | +- org.mortbay.jetty:jsp-2.1:jar:6.1.14:compile
[INFO] | +- org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:compile
[INFO] | +- org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.13:compile
[INFO] | +- tomcat:jasper-compiler:jar:5.5.23:compile
[INFO] | +- tomcat:jasper-runtime:jar:5.5.23:compile
[INFO] | +- org.jamon:jamon-runtime:jar:2.3.1:compile
[INFO] | +- com.lmax:disruptor:jar:3.3.0:compile
[INFO] | +- org.apache.hadoop:hadoop-client:jar:2.5.1:compile
[INFO] | | +- org.apache.hadoop:hadoop-mapreduce-client-app:jar:2.5.1:compile
[INFO] | | | +- org.apache.hadoop:hadoop-mapreduce-client-common:jar:2.5.1:compile
[INFO] | | | | +- org.apache.hadoop:hadoop-yarn-client:jar:2.5.1:compile
[INFO] | | | | | \- com.sun.jersey:jersey-client:jar:1.9:compile
[INFO] | | | | \- org.apache.hadoop:hadoop-yarn-server-common:jar:2.5.1:compile
[INFO] | | | \- org.apache.hadoop:hadoop-mapreduce-client-shuffle:jar:2.5.1:compile
[INFO] | | | \- org.fusesource.leveldbjni:leveldbjni-all:jar:1.8:compile
[INFO] | | +- org.apache.hadoop:hadoop-yarn-api:jar:2.5.1:compile
[INFO] | | \- org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:2.5.1:compile
[INFO] | \- org.apache.hadoop:hadoop-hdfs:jar:2.5.1:compile
[INFO] | \- commons-daemon:commons-daemon:jar:1.0.13:compile
[INFO] +- com.esotericsoftware:kryo:jar:4.0.1:compile
[INFO] | +- com.esotericsoftware:minlog:jar:1.3.0:compile
[INFO] | \- org.objenesis:objenesis:jar:2.5.1:compile
[INFO] +- com.esotericsoftware:reflectasm:jar:1.11.3:compile
[INFO] \- org.ow2.asm:asm:jar:6.0:compile
hbase-server的jar包和kryo的reflectasm依賴之間存在asm字節(jié)碼包之間的沖突紊浩,解決方案是在hbase-server中窖铡,去除對低版本asm字節(jié)碼解析包的依賴:
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>1.1.2</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>