TypeNotPresentExceptionProxy

When upgrading from Surefire 2.6 to Surefire 2.13, I get TypeNotPresentExceptionProxy when I run my unit tests.

 java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653) at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460) at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286) at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69) at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52) at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070) at java.lang.Class.getAnnotation(Class.java:3029) at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:64) 

In JUnit4TestChecker line 64 looks like this:

 Annotation runWithAnnotation = testClass.getAnnotation( runWith ); 

So, Surefire checks the @RunWith annotation to make sure its type is valid. Our tests use Spring, so @RunWith looks like this in our test classes:

 @RunWith(SpringJUnit4ClassRunner.class) 

Surefire does not seem to find the SpringJUnit4ClassRunner class. I'm not sure why, since in Surefire 2.6, tests pass fine.

Any ideas?

+51
java maven exception junit surefire
Feb 01 '13 at 23:02
source share
2 answers

Run mvn dependency: allow

Exclude any version of JUnit 3.x that may have crept in.

Make sure there are no TestNG dependencies if they will load TestNG annotations and not the required JUnit.

+2
Jul 07 '16 at 21:36
source share

The TypeNotPresentExceptionProxy error is not specific to a specific dependency and depends on each path to the project classes. So check out your maven dependency tree. For example, I once got into this error when I had two junit dependencies, so there were two versions of Junit annotations in the classpath.

You can set a breakpoint in some methods of the java.lang.Class class:

For example:

 java.lang.Class.getAnnotation java.lang.Class.getAnnotations 

After that, you can find out which class the problem is with ... find annotations inside the class and check the class path for ambiguities.

0
Apr 29 '19 at 20:59
source share



All Articles