94.273: java.lang.NoClassDefFoundError: org/apache/log4j/Logger during JUnit run

JUnit test runs cannot seem to resolve log4j anymore.  This worked totally fine in the previous EAP, but fails to resolve in 94.273.  I also tried "force re-import all Maven projects" to no good effect.

java.lang.NoClassDefFoundError: org/apache/log4j/Logger

at edu.academyart.model.Profile.<clinit>(Profile.java:22)

at edu.academyart.unit.lms.wicket.DashboardUnitTest.<init>(DashboardUnitTest.java:17)

at edu.academyart.lms.frontend.pages.substitutes.AbstractSubstitutionTest.<init>(AbstractSubstitutionTest.java:14)

at edu.academyart.lms.frontend.pages.substitutes.EditDeleteColumnTest.<init>(EditDeleteColumnTest.java:20)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at org.junit.internal.runners.JUnit4ClassRunner.createTest(JUnit4ClassRunner.java:82)

at edu.academyart.unit.lms.wicket.WicketUnitTestRunner.createTest(WicketUnitTestRunner.java:31)

at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:89)

at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)

at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54)

at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)

at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)

at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52)

at edu.academyart.unit.lms.wicket.WicketUnitTestRunner.run(WicketUnitTestRunner.java:23)

at org.junit.runners.Suite.runChild(Suite.java:117)

at org.junit.runners.Suite.runChild(Suite.java:24)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)

at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)

at org.junit.runners.ParentRunner.run(ParentRunner.java:220)

at org.junit.runner.JUnitCore.run(JUnitCore.java:159)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:60)

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger

at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:315)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)

at java.lang.ClassLoader.loadClass(ClassLoader.java:250)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)

... 29 more

5 comments
Comment actions Permalink

I was 2mm away from creating a youtrack issue on a similar topic this morning, but it turns out there was a scope error in my poms. It /seems/ like 94.273 is actually more correct than earlier versions, although the release notes give no indication of this.

So it may be a good idea to check your pom dependencies for log4j.

0
Comment actions Permalink

Hi Kristian,

We currently have it set to "provided" scope, as it's normally provide by the container in a web environment.  Did you have to add it as a dependency manually via "module settings"?

      <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <scope>provided</scope>
      </dependency>


Thanks
0
Comment actions Permalink

It could be argued that your dependency should be "test" scoped, and that this is indeed more correct than "provided". Try changing it.

I did not have your exact problem, but it was also a provided->test scope issue

0
Comment actions Permalink

On second thoughts, that doesn't really sound too good either. In my case it was ok, because it was one of the servlet api classes that we weren't using from our code . I assume you're referencing log4j from production code which means it has to be at least provided.

According to http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope, provided should be on the test classpath scope, and it seems like it's not, which is probably a bug. I'd file a youtrack if I were you

0

Please sign in to leave a comment.