Question

First of all I am new to HBase and Jetty 8.

I have been trying to get Hbase 0.94.xx and embedded Jetty 8.x to play nice together.

I took the sample code from Lars and updated Hush to use 0.94. Here is the HBase 0.94 update I made. https://github.com/yepher/hbase-book/blob/master/hush/pom.xml When I change the Jetty version from "7.3.1.v20110307" to "8.1.4.v20120524". The compile error for "Credential" is easy to solve by changing the import. The Hush server will start fine but eventually I get this exception:

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)

This is the output from maven for "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] ------------------------------------------------------------------------

I tried lots of things like exclude SL4J, Explicitly include SL4j. I am sure I missing something simple but not quite sure what it is.

As another reference point I tried this project https://github.com/steveliles/jetty-embedded-spring-mvc-noxml/blob/master/pom.xml but when I add HBase/core to the pom.xml I start getting the same problems as above.

Does anyone have a pom.xml that works for Jetty 8.x and HBase 0.94.xx?

Edit:

I added more slf4j exclusions and then explicitly include slf4j

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

I've update the Huch project here with working code: https://github.com/yepher/hbase-book

Was it helpful?

Solution

This exception is raised when there are multiple LocationAwareLogger class with different version in your classpath. You can simply do a grep -R LocationAwareLogger *.jar in your lib directory and figure out which jar containing the class. Then you can exclude it in your pom.xml.

EDIT: I have downloaded your repo and installed it on my machine. After I ran a grep command I got following outputs:

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

It looks like you have not excluded slf4j completely by using the wrong groupId/artifactId combination. You need to update your pom and test again.

Note the logging library version contained in jetty might be conflict with hbase, there are no general solution, you need to figure out which version to use and exclude the other.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top