Monday, September 8, 2014

sun.reflect.annotation.TypeNotPresentExceptionProxy and TestNG

I have the TestNG testuit in my project, which is being run with Ant. Suddenly it began to fail with TypeNotPresentExceptionProxy:

  [testng] Exception in thread "main" java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
  [testng]     at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:653)
  [testng]     at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:460)
  [testng]     at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:286)
  [testng]     at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:222)
  [testng]     at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
  [testng]     at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
  [testng]     at java.lang.Class.initAnnotationsIfNecessary(Class.java:3070)
  [testng]     at java.lang.Class.getAnnotation(Class.java:3029)
  [testng]     at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotationInSuperClasses(JDK15AnnotationFinder.java:85)
  [testng]     at org.testng.internal.annotations.JDK15AnnotationFinder.findAnnotation(JDK15AnnotationFinder.java:149)
....

Google says that apparently it is classpath problem, but which particular one ? Information from stacktrace is very scant... so I decided to debug TestNG.

At-first - I added debug configuration to the <testng /> element in build.xml:
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=1234,server=y,suspend=y"  />
it causes the JVM, which runs tests, suspend after starting and wait for debugger connection on 1234 port.

At-second -  I created remote debug configuration in Eclipse which connects to the 1234 port.

And at-third - I added the breakpoint on the ArrayStoreException raising (in Eclipse - Run -> Add Java Exception Breakpoint...).

Then I run Ant, attached debugger, caught  exception and figured out the problem. Indeed, the issue was in classpath :)



No comments:

Post a Comment