[ https://issues.apache.org/jira/browse/MRUNIT-219?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Schmeißer updated MRUNIT-219: ------------------------------------- Priority: Minor (was: Major) > Missing log4j dependency causes runtime exception in tests > ---------------------------------------------------------- > > Key: MRUNIT-219 > URL: https://issues.apache.org/jira/browse/MRUNIT-219 > Project: MRUnit > Issue Type: Bug > Affects Versions: 1.0.0, 1.1.0 > Environment: JUnit 4.11 test > Windows 7 > Java 7 > Gradle 2.0 > Hadoop 2.5.0-cdh5.2.0 > Reporter: Michael Schmeißer > Priority: Minor > Labels: junit > > We have recently moved our project to log4j2 and removed the SLF4J / log4j1 > dependency. This resulted in tests failing with the following exception: > {code:title=Stacktrace|borderStyle=solid} > java.lang.NoClassDefFoundError: org/apache/log4j/Level > at org.apache.hadoop.mapred.JobConf.<clinit>(JobConf.java:348) > at org.apache.hadoop.mapreduce.counters.Limits.<clinit>(Limits.java:30) > at > org.apache.hadoop.mapreduce.counters.AbstractCounters.<init>(AbstractCounters.java:87) > at org.apache.hadoop.mapreduce.Counters.<init>(Counters.java:139) > at > org.apache.hadoop.mrunit.mapreduce.MapDriver.<init>(MapDriver.java:74) > at > org.apache.hadoop.mrunit.mapreduce.MapDriver.newMapDriver(MapDriver.java:208) > at mypackage.MyTest.prepare(MyTest.java:35) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) > at org.junit.runners.ParentRunner.run(ParentRunner.java:309) > at org.junit.runners.Suite.runChild(Suite.java:127) > at org.junit.runners.Suite.runChild(Suite.java:26) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) > at org.junit.runners.ParentRunner.run(ParentRunner.java:309) > at org.junit.runner.JUnitCore.run(JUnitCore.java:160) > at > com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) > at > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) > at > com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121) > Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level > at java.net.URLClassLoader$1.run(URLClassLoader.java:366) > at java.net.URLClassLoader$1.run(URLClassLoader.java:355) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:354) > at java.lang.ClassLoader.loadClass(ClassLoader.java:425) > at java.lang.ClassLoader.loadClass(ClassLoader.java:358) > ... 46 more > {code} > Adding log4j1 as test scope dependency like this (Gradle) solves the problem: > {noformat} > testCompile group: 'log4j', name: 'log4j', version: '1.2.16' > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)