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(

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

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(

at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(

at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(

at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(

at $Proxy3.processTestClass(Unknown Source)

at org.gradle.api.internal.tasks.testing.worker.TestWorker$

at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(

at java.util.concurrent.ThreadPoolExecutor$

at 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(

at org.junit.internal.runners.JUnit4ClassRunner.runMethods(

at org.junit.internal.runners.JUnit4ClassRunner$

at org.junit.internal.runners.ClassRoadie.runUnprotected(

at org.junit.internal.runners.ClassRoadie.runProtected(



at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(

at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(

at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(

… 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 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.