1

首先,我是 HBase 和 Jetty 8 的新手。

我一直试图让 Hbase 0.94.xx 和嵌入式 Jetty 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”时。通过更改导入可以轻松解决“凭据”的编译错误。Hush 服务器将正常启动,但最终我得到了这个异常:

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)

这是 maven 的“包含 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>

我在这里用工作代码更新了 Huch 项目:https ://github.com/yepher/hbase-book

4

1 回答 1

1

当您的类路径中有多个LocationAwareLogger具有不同版本的类时,会引发此异常。您可以简单地grep -R LocationAwareLogger *.jar在您的 lib 目录中执行 a 并找出包含该类的 jar。然后你可以将它排除在你的pom.xml.

编辑:我已经下载了你的 repo 并将它安装在我的机器上。运行grep命令后,我得到以下输出:

eric@localhost: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
eric@localhost: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

看起来您没有slf4j完全排除使用错误的groupId/artifactId组合。您需要更新您的 pom 并再次测试。

注意jetty中包含的日志库版本可能与hbase冲突,没有通用的解决方案,你需要弄清楚使用哪个版本并排除另一个。

于 2013-03-05T16:18:48.860 回答