0

I have met with the following exception and it's the first time I came across with this one:

Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Level
    at org.apache.hadoop.mapred.JobConf.<clinit>(JobConf.java:357) ~[hadoop-mapreduce-client-core-2.7.1.jar:na]
    at java.lang.Class.forName0(Native Method) ~[na:1.8.0_91]
    at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_91]
    at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2134) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:95) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:78) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:136) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.Groups.<init>(Groups.java:79) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.Groups.<init>(Groups.java:74) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.Groups.getUserToGroupsMappingService(Groups.java:303) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:283) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:260) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:790) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:760) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:633) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2812) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2802) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2668) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:371) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:170) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:355) ~[hadoop-common-2.7.1.jar:na]
    at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295) ~[hadoop-common-2.7.1.jar:na]
    at org.springframework.data.hadoop.store.support.OutputStoreObjectSupport.findInitFiles(OutputStoreObjectSupport.java:110) ~[spring-data-hadoop-store-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.hadoop.store.support.OutputStoreObjectSupport.initOutputContext(OutputStoreObjectSupport.java:93) ~[spring-data-hadoop-store-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.hadoop.store.support.OutputStoreObjectSupport.onInit(OutputStoreObjectSupport.java:83) ~[spring-data-hadoop-store-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.data.hadoop.store.support.LifecycleObjectSupport.afterPropertiesSet(LifecycleObjectSupport.java:67) ~[spring-data-hadoop-store-2.3.0.RELEASE.jar:2.3.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
    ... 66 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_91]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_91]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_91]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_91]
    ... 94 common frames omitted

I have tried this. But it doesn't solves the problem. Also looked at here and it too disappointed.

Any help will be appreciated.

Community
  • 1
  • 1
Abhishek Ramachandran
  • 1,160
  • 1
  • 13
  • 34

2 Answers2

2

It seems that the class:

org.apache.log4j.Level

can't be found in your classpath. First, make sure that Log4j dependency is in your local repository, i.e. in your .m2 folder, if it's not there, execute on your command-line:

mvn dependency:copy-dependencies

That Maven command will pull down your requested dependencies which aren't found in your local repository.

Moshe Arad
  • 3,587
  • 4
  • 18
  • 33
2

I just solved this issue. It's all because of a wrong code placed in build.gradle as

configurations.all {
    exclude group: "commons-logging", module: "commons-logging"
    exclude group: "log4j", module: "log4j"
 }

Removed this and problem solved.

Abhishek Ramachandran
  • 1,160
  • 1
  • 13
  • 34