HBase 1.1.2 + Kryo 4.0.1组合使用,kryo将数据序列化为byte数组后入到HBase中,查询程序将HBase取出来后,调用Kryo反序列化,突然出现了下面的错误,出现了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命令查看依赖树结果如下:
[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字节码包之间的冲突,解决方案是在hbase-server中,去除对低版本asm字节码解析包的依赖:
<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>
网友评论