java.lang.ClassNotFoundException:org.apache.log4j.Level Exception

时间:2016-09-03 11:25:43

标签: java spring log4j slf4j

我遇到了以下异常,这是我第一次遇到这个:

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

我试过this。但它并没有解决问题。还看了here而且太失望了。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

似乎是班级:

  

org.apache.log4j.Level

在您的类路径中找不到

。 首先,确保Log4j依赖项在您的本地存储库中,即在.m2文件夹中,如果它不存在,请在命令行上执行:

mvn dependency:copy-dependencies

Maven命令将下拉您在本地存储库中找不到的请求的依赖项。

答案 1 :(得分:1)

我刚刚解决了这个问题。这都是因为/** * "StopPlayWithAVSpeechSynthesizer" : this method will stop the playing of audio on the application. */ -(void)StopPlayWithAVSpeechSynthesizer{ // Do any additional setup after loading the view, typically from a nib. [synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate]; } 中的错误代码为

build.gradle

删除了这个并解决了问题。