Not compatible with TestNG 5.4: InstantiationException: 
org.testng.internal.annotations.JDK15AnnotationFinder
-------------------------------------------------------------------------------------------------------------

                 Key: SUREFIRE-58
                 URL: http://jira.codehaus.org/browse/SUREFIRE-58
             Project: surefire
          Issue Type: Bug
    Affects Versions: 2.2
         Environment: JDK  1.5.0_09
mvn 2.0.4
surefire-api:jar:2.0
surefire-testng:jar:2.0

<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.2</version>
      </plugin>

 <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>5.4</version>
      <classifier>jdk15</classifier>
      <scope>test</scope>
    </dependency>
            Reporter: Damian Golda
            Priority: Minor


While running test using mvn and TestNG 5.4 there surefire reports exception:

org.apache.maven.surefire.booter.SurefireExecutionException: 
org.testng.internal.annotations.JDK15AnnotationFinder; nes
ed exception is java.lang.InstantiationException: 
org.testng.internal.annotations.JDK15AnnotationFinder; nested excepti
n is org.apache.maven.surefire.testset.TestSetFailedException: 
org.testng.internal.annotations.JDK15AnnotationFinder; n
sted exception is java.lang.InstantiationException: 
org.testng.internal.annotations.JDK15AnnotationFinder
org.apache.maven.surefire.testset.TestSetFailedException: 
org.testng.internal.annotations.JDK15AnnotationFinder; nested
exception is java.lang.InstantiationException: 
org.testng.internal.annotations.JDK15AnnotationFinder
java.lang.InstantiationException: 
org.testng.internal.annotations.JDK15AnnotationFinder
        at java.lang.Class.newInstance0(Class.java:335)
        at java.lang.Class.newInstance(Class.java:303)
        at 
org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.<init>(TestNGDirectoryTestSuite.java:86)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at 
org.apache.maven.surefire.Surefire.instantiateObject(Surefire.java:216)
        at 
org.apache.maven.surefire.Surefire.instantiateSuite(Surefire.java:243)
        at 
org.apache.maven.surefire.Surefire.createSuiteFromDefinition(Surefire.java:145)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
        at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)


I suppose that the reason is that in TestNG 5.4 (and 5.3) constructor for 
JDK15AnnotationFinder has an argument:

public JDK15AnnotationFinder(IAnnotationTransformer transformer) 

and there is no default constructor.

I found that there is only one implementation of IAnnotationTransformer - 
DefaultAnnotationTransformer which fortunatly has default constructor.
So I it can be changed from 
new JDK15AnnotationFinder() 
to 
new JDK15AnnotationFinder(new DefaultAnnotationTransformer())

So instead of class.newInstance should be used:
Constructor c = Class.getConstructor(IAnnotationTransformer.class);
DefaultAnnotationTransformer daf = new DefaultAnnotationTransformer()
 c.newInstance(daf);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to