Build works on Mac OSX but fails with java.lang.NoSuchMethodError for JUnit class on Red Hat


(Steven Ford) #1

I run my gradle build on my Mac OSX and it is successful. The same project fails on our CI server (Red Hat Linux). The error I get on the CI server is:

java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V

I know this has to do with the Junit & Spring version, but as I say it works locally (Mac OSX) and I have tried several variations of Junit & Spring versions. Most notably is to use Junit 4.4, which is how the problem was solved when I ran into it a long time ago when building with ant.

The only small difference I see is the Groovy version (mac: 1.8.6 ci: 1.8.4).

Has anyone else seen this? Any suggestions? I am using Gradle 1.0-milestone-7. I am running this from the command line in both environments.


(Peter Niederwieser) #2

Please provide the full stack trace.


(Steven Ford) #3

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not execute test class ‘com.lifeway.easervices.address.repository.CountyByZipProcedureTest’.

at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)

at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)

at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)

at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:75)

at $Proxy3.processTestClass(Unknown Source)

at org.gradle.api.internal.tasks.testing.worker.TestWorker$1.run(TestWorker.java:103)

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V

at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:155)

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 org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:51)

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:63)

at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)

… 13 more


(Peter Niederwieser) #4

Seems like you are using Spring’s TestContext framework together with an incompatible version of JUnit. Do you declare an explicit dependency on JUnit in your build? Otherwise you are taking chances. For example, different versions of Groovy could pull in different versions of JUnit. I don’t think the problem is related to OS per se.


(Steven Ford) #5

Peter, Thanks for your response. Yes I do specify my junit & spring in my dependancies. What I don’t get is that it is the same gradle.build in both environments so both should be using the exact same version of everything


(Peter Niederwieser) #6

If it’s the exact same build, then why are the Groovy versions different?

Have you checked and compared the test task class path in both environments?

task showTestTaskClasspath << {
  test.classpath.each { println it }
}

(Luke Daley) #7

Hi Steven,

Did you manage to resolve this?


(Steven Ford) #8

Yes. The main issue was already known, I had to use junit 4.4 with Spring 2.5. The cause of my issue is that I had a dependency that was dependent on a newer version oj JUnit. On my CI Box the classpath was loaded in a different order than on my Mac.