org.testng.TestNGException: Cannot instantiate class XyzTest

Jenkins JIRA | kutzi | 7 years ago
  1. 0

    Occasionally we have some test which lets Surefire fail hard which Hudson doesn't recognize. I.e. the tests are not executed, but the build result is still success. E.g. we had a test which failed with a NoSuchFieldException in the constructor of the test class: Running TestSuite log4j:WARN No appenders could be found for logger (...). log4j:WARN Please initialize the log4j system properly. org.apache.maven.surefire.booter.SurefireExecutionException: Cannot instantiate class XyzTest; nested exception is org.testng.TestNGException: Cannot instantiate class XyzTest org.testng.TestNGException: Cannot instantiate class XyzTest at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:35) at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:330) at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:62) at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:81) at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:114) at org.testng.TestRunner.initMethods(TestRunner.java:289) at org.testng.TestRunner.init(TestRunner.java:235) at org.testng.TestRunner.init(TestRunner.java:197) at org.testng.TestRunner.<init>(TestRunner.java:141) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:488) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:250) at org.testng.SuiteRunner.run(SuiteRunner.java:204) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877) at org.testng.TestNG.runSuitesLocally(TestNG.java:842) at org.testng.TestNG.run(TestNG.java:751) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) 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:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) Caused by: java.lang.reflect.InvocationTargetException 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:513) at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:26) ... 23 more Caused by: java.lang.NoSuchFieldException: cipherService at java.lang.Class.getDeclaredField(Class.java:1882) at XyzTest.<init>(XyzTest.java:91) ... 28 more [ERROR] There are test failures.

    Jenkins JIRA | 7 years ago | kutzi
    org.testng.TestNGException: Cannot instantiate class XyzTest
  2. 0

    Occasionally we have some test which lets Surefire fail hard which Hudson doesn't recognize. I.e. the tests are not executed, but the build result is still success. E.g. we had a test which failed with a NoSuchFieldException in the constructor of the test class: Running TestSuite log4j:WARN No appenders could be found for logger (...). log4j:WARN Please initialize the log4j system properly. org.apache.maven.surefire.booter.SurefireExecutionException: Cannot instantiate class XyzTest; nested exception is org.testng.TestNGException: Cannot instantiate class XyzTest org.testng.TestNGException: Cannot instantiate class XyzTest at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:35) at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:330) at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:62) at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:81) at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:114) at org.testng.TestRunner.initMethods(TestRunner.java:289) at org.testng.TestRunner.init(TestRunner.java:235) at org.testng.TestRunner.init(TestRunner.java:197) at org.testng.TestRunner.<init>(TestRunner.java:141) at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:488) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:250) at org.testng.SuiteRunner.run(SuiteRunner.java:204) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877) at org.testng.TestNG.runSuitesLocally(TestNG.java:842) at org.testng.TestNG.run(TestNG.java:751) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141) at org.apache.maven.surefire.Surefire.run(Surefire.java:180) 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:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021) Caused by: java.lang.reflect.InvocationTargetException 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:513) at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:26) ... 23 more Caused by: java.lang.NoSuchFieldException: cipherService at java.lang.Class.getDeclaredField(Class.java:1882) at XyzTest.<init>(XyzTest.java:91) ... 28 more [ERROR] There are test failures.

    Jenkins JIRA | 7 years ago | kutzi
    org.testng.TestNGException: Cannot instantiate class XyzTest
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    PIG Job fails when using ISOHoursBetween() UDF

    Stack Overflow | 3 years ago | ajay
    java.lang.NoSuchFieldException: jobsInProgress
  5. 0

    Unable to access binding information for class

    Stack Overflow | 3 years ago | Anthony Cavanagh
    java.lang.NoSuchFieldException: JiBX_bindingList

  1. davidvanlaatum 2 times, last 1 week ago
  2. Aria Pahlavan 12 times, last 1 week ago
  3. filpgame 1 times, last 2 weeks ago
  4. bmacedo 4 times, last 1 week ago
  5. franky li 11 times, last 1 month ago
29 more registered users
21 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.NoSuchFieldException

    cipherService

    at java.lang.Class.getDeclaredField()
  2. Java RT
    Class.getDeclaredField
    1. java.lang.Class.getDeclaredField(Class.java:1882)
    1 frame
  3. Unknown
    XyzTest.<init>
    1. XyzTest.<init>(XyzTest.java:91)
    1 frame
  4. Java RT
    Constructor.newInstance
    1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    4. java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    4 frames
  5. TestNG
    TestNG.run
    1. org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:26)
    2. org.testng.internal.ClassHelper.createInstance(ClassHelper.java:330)
    3. org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:62)
    4. org.testng.internal.ClassImpl.getInstances(ClassImpl.java:81)
    5. org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:114)
    6. org.testng.TestRunner.initMethods(TestRunner.java:289)
    7. org.testng.TestRunner.init(TestRunner.java:235)
    8. org.testng.TestRunner.init(TestRunner.java:197)
    9. org.testng.TestRunner.<init>(TestRunner.java:141)
    10. org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:488)
    11. org.testng.SuiteRunner.privateRun(SuiteRunner.java:250)
    12. org.testng.SuiteRunner.run(SuiteRunner.java:204)
    13. org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:877)
    14. org.testng.TestNG.runSuitesLocally(TestNG.java:842)
    15. org.testng.TestNG.run(TestNG.java:751)
    15 frames
  6. org.apache.maven
    TestNGDirectoryTestSuite.execute
    1. org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
    2. org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
    2 frames
  7. SureFire
    Surefire.run
    1. org.apache.maven.surefire.Surefire.run(Surefire.java:180)
    1 frame
  8. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  9. SureFire
    SurefireBooter.main
    1. org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
    2. org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
    2 frames