首先,我是HBase和Jetty8的新手。
我一直在尝试让Hbase 0.94.xx和embedded Jetty 8.x能够很好地结合在一起。
我从Lars获取了示例代码,并将Hush更新为使用0.94。这是我所做的HBase 0.94更新。Jetty版本从"7.3.1.v20110307“改为"8.1.4.v20120524”时https://github.com/yepher/hbase-book/blob/master/hush/pom.xml。"Credential“的编译错误很容易通过更改导入来解决。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对"includes 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。我确信我错过了一些简单的东西,但不太确定它是什么。
作为另一个参考点,我尝试了这个项目核心,但是当我向pom.xml添加HBase/ https://github.com/steveliles/jetty-embedded-spring-mvc-noxml/blob/master/pom.xml时,我开始得到与上面相同的问题。
有没有人有支持Jetty8.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
发布于 2013-03-06 00:18:49
当类路径中有多个版本不同的LocationAwareLogger
类时,会引发此异常。您可以简单地在lib目录中执行一个grep -R LocationAwareLogger *.jar
,并找出包含该类的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
看起来您并没有通过使用错误的groupId
/artifactId
组合来完全排除slf4j
。您需要更新您的pom并再次测试。
注意jetty中包含的日志记录库版本可能与hbase冲突,没有通用的解决方案,您需要确定使用哪个版本并排除其他版本。
https://stackoverflow.com/questions/15228287
复制相似问题