2013-03-05 31 views
1

首先我是新來的HBase和Jetty 8HBASE 0.94.xxx與碼頭8.xxx

我一直在試圖讓HBase的0.94.xx和嵌入式碼頭8.x中發揮好起來。

我從Lars採取了示例代碼並更新了Hush以使用0.94。這是我做的HBase 0.94更新。 https://github.com/yepher/hbase-book/blob/master/hush/pom.xml當我將Jetty版本從「7.3.1.v20110307」更改爲「8.1.4.v20120524」時。 「Credential」的編譯錯誤很容易通過更改導入來解決。該噓服務器將開始不錯,但最終我得到這個異常:

Exception in thread "main" java.lang.NoSuchMethodError: 
org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V 
    at 
org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:601) 
    at 
org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:425) 
    at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:64) at 
org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:199) 
    at 
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69) 
    at com.hbasebook.hush.HushMain.main(HushMain.java:112) 

這是行家的輸出爲「包括sl4j」

[hush (master)]$ mvn dependency:tree -Dincludes=org.slf4j 
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java... 
[INFO] Scanning for projects... 
Downloading: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-maven-plugin/8.1.4.v20120524/jetty-maven-plugin-8.1.4.v20120524.pom 
Downloaded: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-maven-plugin/8.1.4.v20120524/jetty-maven-plugin-8.1.4.v20120524.pom (7 KB at 14.5 KB/sec) 
Downloading: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-integration-project/8.1.4.v20120524/jetty-integration-project-8.1.4.v20120524.pom 
Downloaded: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-integration-project/8.1.4.v20120524/jetty-integration-project-8.1.4.v20120524.pom (12 KB at 298.1 KB/sec) 
Downloading: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-maven-plugin/8.1.4.v20120524/jetty-maven-plugin-8.1.4.v20120524.jar 
Downloaded: http://repo1.maven.org/maven2/org/mortbay/jetty/jetty-maven-plugin/8.1.4.v20120524/jetty-maven-plugin-8.1.4.v20120524.jar (70 KB at 758.4 KB/sec) 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building HBase URL Shortener 1.0 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ hush --- 
[INFO] com.hbasebook:hush:war:1.0 
[INFO] \- org.apache.hbase:hbase:jar:0.94.3:compile 
[INFO] +- org.slf4j:slf4j-api:jar:1.4.3:compile 
[INFO] \- org.slf4j:slf4j-log4j12:jar:1.4.3:compile 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.987s 
[INFO] Finished at: Tue Mar 05 09:51:40 CST 2013 
[INFO] Final Memory: 8M/81M 
[INFO] ------------------------------------------------------------------------ 

我試過很多東西像排除SL4J,明確包括SL4j 。我相信我錯過了一些簡單但不太確定的事情。

作爲另一個參考點,我嘗試了這個項目https://github.com/steveliles/jetty-embedded-spring-mvc-noxml/blob/master/pom.xml,但是當我將HBase/core添加到pom.xml時,我開始遇到與上面相同的問題。

有沒有人有一個適用於Jetty 8.x和HBase 0.94.xx的pom.xml?

編輯:

我增加了更多的SLF4J排除,然後明確包括SLF4J

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-log4j12</artifactId> 
    <version>1.6.4</version>       
</dependency> 

我已經有工作代碼在這裏更新胡赫項目:https://github.com/yepher/hbase-book

回答

1

,引發此異常時,有是類路徑中多個LocationAwareLogger類的不同版本。你可以簡單地在你的lib目錄中做一個grep -R LocationAwareLogger *.jar,並找出哪個jar包含這個類。然後你可以在你的pom.xml中排除它。

編輯: 我已下載您的回購並將其安裝在我的機器上。之後,我跑了grep命令我得到了以下成果:

[email protected]:hbase-book$ grep -R 'org/slf4j/spi/LocationAwareLogger' hush/target/hush/WEB-INF/lib/*.jar 
Binary file hush/target/hush/WEB-INF/lib/slf4j-api-1.6.4.jar matches 
[email protected]:hbase-book$ grep -R 'org/slf4j/LoggerFactory' hush/target/hush/WEB-INF/lib/*.jar 
Binary file hush/target/hush/WEB-INF/lib/slf4j-api-1.6.4.jar matches 

它看起來像你沒有用錯了groupId/artifactId組合排除slf4j完全。你需要更新你的POM並再次測試。

注意jetty中包含的日誌庫版本可能與hbase衝突,沒有通用的解決方案,您需要確定要使用哪個版本並排除其他版本。

+0

當我排除的jar我得到這個錯誤在啓動時: 異常在線程「主要」 java.lang.NoClassDefFoundError:組織/ SLF4J /的LoggerFactory \t在org.apache.zookeeper.ZooKeeper。 (ZooKeeper.java:93) – Yepher 2013-03-05 16:54:34

相關問題