我的本地环境:OSX 10.9.2,java1.6
我使用java api连接hbase和maven来管理我的项目,我将hbase-0.94.17和Hadoop-core-1.0.4添加到pom.xml中,当我运行我的.java程序连接Hbase时我得到了以下错误:
SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x.
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:107)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:295)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at org.apache.zookeeper.ZooKeeper.<clinit>(ZooKeeper.java:94)
at org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper.<init>(RecoverableZooKeeper.java:98)
at org.apache.hadoop.hbase.zookeeper.ZKUtil.connect(ZKUtil.java:127)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:153)
at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.<init>(ZooKeeperWatcher.java:127)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getZooKeeperWatcher(HConnectionManager.java:1505)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.ensureZookeeperTrackers(HConnectionManager.java:713)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:983)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:958)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:251)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:155)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:129)
at org.geogit.storage.hbase.MyLittleHBaseClient.main(MyLittleHBaseClient.java:29)
这是我在运行mvm依赖后得到的:树
INFO] --- maven-dependency-plugin:2.2:tree (default-cli) @ geogit-hbase ---
[INFO] org.geogit:geogit-hbase:jar:0.8-SNAPSHOT
[INFO] +- org.geogit:geogit-core:jar:0.8-SNAPSHOT:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] | +- com.vividsolutions:jts:jar:1.13:compile
[INFO] | +- org.geotools:gt-opengis:jar:10.5:compile
[INFO] | | +- net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2:compile
[INFO] | | +- java3d:vecmath:jar:1.3.2:compile
[INFO] | | +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] | | \- javax.media:jai_core:jar:1.1.3:compile
[INFO] | +- org.geotools:gt-referencing:jar:10.5:compile
[INFO] | | +- org.geotools:gt-metadata:jar:10.5:compile
[INFO] | | \- jgridshift:jgridshift:jar:1.0:compile
[INFO] | +- org.geotools:gt-epsg-hsql:jar:10.5:compile
[INFO] | | \- hsqldb:hsqldb:jar:1.8.0.7:compile
[INFO] | +- org.geotools:gt-main:jar:10.5:compile
[INFO] | | \- org.geotools:gt-api:jar:10.5:compile
[INFO] | +- org.geotools:gt-cql:jar:10.5:compile
[INFO] | +- net.sourceforge.findbugs:jsr305:jar:1.3.7:compile
[INFO] | +- com.google.inject:guice:jar:3.0:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- com.google.inject.extensions:guice-multibindings:jar:3.0:compile
[INFO] | +- com.google.code.gson:gson:jar:2.2.2:compile
[INFO] | \- com.ning:compress-lzf:jar:0.9.8:compile
[INFO] +- org.apache.hbase:hbase-client:jar:0.98.0-hadoop2:compile
[INFO] | +- org.apache.hbase:hbase-common:jar:0.98.0-hadoop2:compile
[INFO] | | +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] | | \- log4j:log4j:jar:1.2.17:compile
[INFO] | +- org.apache.hbase:hbase-protocol:jar:0.98.0-hadoop2:compile
[INFO] | +- commons-codec:commons-codec:jar:1.7:compile
[INFO] | +- commons-io:commons-io:jar:2.4:compile
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
[INFO] | +- io.netty:netty:jar:3.6.6.Final:compile
[INFO] | +- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
[INFO] | | \- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[INFO] | +- org.cloudera.htrace:htrace-core:jar:2.04:compile
[INFO] | | \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.8.8:compile
[INFO] | | \- org.codehaus.jackson:jackson-core-asl:jar:1.8.8:compile
[INFO] | +- org.apache.hadoop:hadoop-common:jar:2.2.0:compile
[INFO] | | +- commons-cli:commons-cli:jar:1.2:compile
[INFO] | | +- org.apache.commons:commons-math:jar:2.1:compile
[INFO] | | +- xmlenc:xmlenc:jar:0.52:compile
[INFO] | | +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] | | +- commons-net:commons-net:jar:3.1:compile
[INFO] | | +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] | | +- com.sun.jersey:jersey-core:jar:1.9:compile
[INFO] | | +- com.sun.jersey:jersey-json:jar:1.9:compile
[INFO] | | | +- org.codehaus.jettison:jettison:jar:1.0.1:compile (version managed from 1.1)
[INFO] | | | | \- stax:stax-api:jar:1.0.1:compile
[INFO] | | | +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] | | | | \- javax.xml.bind:jaxb-api:jar:2.2.2:compile
[INFO] | | | | \- javax.activation:activation:jar:1.1:compile
[INFO] | | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
[INFO] | | | \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
[INFO] | | +- commons-el:commons-el:jar:1.0:runtime
[INFO] | | +- net.java.dev.jets3t:jets3t:jar:0.6.1:compile
[INFO] | | +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] | | | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | | | \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] | | | \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] | | +- org.apache.avro:avro:jar:1.7.4:compile
[INFO] | | | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
[INFO] | | | \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile
[INFO] | | +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] | | \- org.apache.commons:commons-compress:jar:1.4.1:compile
[INFO] | | \- org.tukaani:xz:jar:1.0:compile
[INFO] | +- org.apache.hadoop:hadoop-auth:jar:2.2.0:compile
[INFO] | +- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.2.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-yarn-common:jar:2.2.0:compile
[INFO] | | | +- org.apache.hadoop:hadoop-yarn-api:jar:2.2.0:compile
[INFO] | | | +- com.sun.jersey:jersey-server:jar:1.9:compile
[INFO] | | | | \- asm:asm:jar:3.1:compile
[INFO] | | | \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
[INFO] | | \- com.google.inject.extensions:guice-servlet:jar:3.0:compile
[INFO] | +- org.apache.hadoop:hadoop-annotations:jar:2.2.0:compile
[INFO] | \- com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile
[INFO] +- org.geogit:geogit-mongodb:jar:0.8-SNAPSHOT:compile
[INFO] | +- org.geogit:geogit-blueprints:jar:0.8-SNAPSHOT:compile
[INFO] | | +- com.tinkerpop.blueprints:blueprints-core:jar:2.4.0:compile
[INFO] | | | +- com.fasterxml.jackson.datatype:jackson-datatype-json-org:jar:2.1.2:compile
[INFO] | | | | +- com.fasterxml.jackson.core:jackson-core:jar:2.1.2:compile
[INFO] | | | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.1.2:compile
[INFO] | | | | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.1.1:compile
[INFO] | | | | \- org.json:json:jar:20090211:compile
[INFO] | | | \- colt:colt:jar:1.2.0:compile
[INFO] | | | \- concurrent:concurrent:jar:1.3.4:compile
[INFO] | | \- com.tinkerpop.gremlin:gremlin-java:jar:2.4.0:compile
[INFO] | | \- com.tinkerpop:pipes:jar:2.4.0:compile
[INFO] | \- org.mongodb:mongo-java-driver:jar:2.11.3:compile
[INFO] +- com.google.guava:guava:jar:14.0.1:compile
[INFO] +- org.geogit:geogit-core:jar:tests:0.8-SNAPSHOT:test
[INFO] \- junit:junit:jar:4.10:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.1:test
在这里我附上我的pom.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.geogit</groupId>
<artifactId>storage</artifactId>
<version>0.8-SNAPSHOT</version>
</parent>
<groupId>org.geogit</groupId>
<artifactId>geogit-hbase</artifactId>
<packaging>jar</packaging>
<name>HBase Storage for GeoGit objects</name>
<dependencies>
<dependency>
<groupId>org.geogit</groupId>
<artifactId>geogit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.94.17</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.4</version>
</dependency>
<!-- is this necessary? -->
<!--
<dependency>
<groupId>com.boundlessgeo</groupId>
<artifactId>blongo</artifactId>
<version>0.1</version>
</dependency>
-->
<!-- is this necessary? -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- Test scope dependencies -->
<dependency>
<groupId>org.geogit</groupId>
<artifactId>geogit-core</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
</profiles>
</project>
答案 0 :(得分:4)
拥有slf4j-api
并选择相应版本的SLF4J绑定,并将它们作为依赖项添加到您自己的POM中。您的某些依赖项可能会传递性地解决导致该问题的SLF4J绑定的不兼容版本。找出哪个库引入了不需要的SLF4J绑定(您可以通过mvn dependency:tree
轻松完成),并在您的依赖项中添加相应的排除项。
(通常不应在库中声明SLF4J绑定。实际上,一旦找到实际原因,您可能想要向库开发人员报告是错误的)
更新
这正是我所说的:
从依赖关系树:
[INFO] +- org.geogit:geogit-core:jar:0.8-SNAPSHOT:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.5:compile
.....
[INFO] +- org.apache.hbase:hbase-client:jar:0.98.0-hadoop2:compile
.....
[INFO] | +- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
[INFO] | | \- org.slf4j:slf4j-log4j12:jar:1.6.1:compile
您从slf4j-log4j12
获得hbase-client
绑定,而版本为1.6.1
但是,您项目中的slf4j-api
版本为1.7.5。它们不兼容。
正确的解决方法是:
slf4j-log4j12
hbase-client
您还应该将此报告为zookeeper / hbase开发人员的错误,因为它不适合库将SLF4J绑定包含为编译范围依赖项。