0

I have tons of tests that run as JUnit tests in my eclipse.

Iv'e just upgraded to spring 4.0.3 from spring 3.X and whenever i try to execute a junit test i get an immidiate exception :

java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.isInJavaLangAnnotationPackage(Ljava/lang/annotation/Annotation;)Z
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:126)
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:137)
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:137)
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:96)
at org.springframework.test.context.ContextLoaderUtils.resolveActiveProfiles(ContextLoaderUtils.java:499)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:722)
at org.springframework.test.context.ContextLoaderUtils.buildMergedContextConfiguration(ContextLoaderUtils.java:656)
at org.springframework.test.context.DefaultTestContext.<init>(DefaultTestContext.java:93)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:119)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:120)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:109)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

my gradle dependencies file:

repositories { mavenCentral() }

  dependencies {
compile group: 'javax.servlet', name:'servlet-api', version:'2.5'
compile group: 'org.springframework', name:'spring-beans', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-messaging', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-websocket', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-context', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-core', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-expression', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-web', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name: 'spring-jms', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version:'4.0.3.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-mongodb', version:'1.3.2.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version:'1.4.2.RELEASE'
compile group: 'org.springframework.security', name:'spring-security-core', version:'3.2.0.RELEASE'
compile group: 'org.springframework.security', name:'spring-security-web', version:'3.2.3.RELEASE'
compile group: 'org.springframework.security', name:'spring-security-config',  version:'3.2.0.RELEASE'
compile group: 'org.springframework', name:'spring-context-support', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-instrument', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-aop', version:'4.0.3.RELEASE'
compile group: 'org.springframework', name:'spring-support', version:'2.0.8'

...
testCompile group: 'junit', name: 'junit', version: '4.+'

Here is my base test class:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/application-context.xml" })
public abstract class BaseTest { ... }

Any ideas what is going on?

Urbanleg
  • 6,252
  • 16
  • 76
  • 139
  • You appear to still have old `spring-core` in your classpath. Check that the only new JAR versions are there. You may want to try to refresh Eclipse dependencies as well. – pingw33n May 27 '14 at 14:28
  • You were right, the dependencies above are not all the dependencies i had. some of them were old (3.X spring dependencies). Thanks! – Urbanleg May 27 '14 at 14:47

0 Answers0