Uploaded image for project: 'MRUnit'
  1. MRUnit
  2. MRUNIT-219

Missing log4j dependency causes runtime exception in tests

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.0.0, 1.1.0
    • None
    • JUnit 4.11 test
      Windows 7
      Java 7
      Gradle 2.0
      Hadoop 2.5.0-cdh5.2.0

    Description

      We have recently moved our project to log4j2 and removed the SLF4J / log4j1 dependency. This resulted in tests failing with the following exception:

      Stacktrace
      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
      

      Adding log4j1 as test scope dependency like this (Gradle) solves the problem:

      testCompile group: 'log4j', name: 'log4j', version: '1.2.16'
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Skamandros Michael Schmei├čer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: