One idea is, you can use the exclusion property of maven (provided you are using that to build your application) while including hadoop dependencies and exclude sl4j that is coming within hadoop and then include your own sl4j as a separate dependency. Something like this:
<dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase</artifactId> <version>0.92.1-cdh4.1.2</version> <exclusions> <exclusion> <artifactId>log4j</artifactId> <groupId>log4j</groupId> </exclusion> <exclusion> <artifactId>slf4j-log4j12</artifactId> <groupId>org.slf4j</groupId> </exclusion> </exclusions> </dependency> Regards, Shahab On Tue, Aug 27, 2013 at 11:47 AM, jamal sasha <[email protected]> wrote: > Hi, > For one of my map reduce code I want to use a different version of slf4j > jar (1.6.4) > But I guess hadoop has a different version of jar in hadoop > classpath lib/slf4j-log4j12-1.4.3.jar > And when I am trying to run my code, I am gettign this error: > 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.apache.commons.logging.impl.SLF4JLocationAwareLog.info > (SLF4JLocationAwareLog.java:159) > at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:931) > at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:416) > at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1093) > at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850) > at org.apache.hadoop.mapreduce.Job.submit(Job.java:500) > at org.rdf.RdfFormatter.run(RdfFormatter.java:109) > at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65) > at org.rdf.RdfFormatter.main(RdfFormatter.java:144) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:616) > at org.apache.hadoop.util.RunJar.main(RunJar.java:156) > > > Similar issue here: > http://stackoverflow.com/questions/10354785/nosuchmethoderror-with-slfj4 > > What should I do? > Thanks >
