1

I am trying to execute a testng.XML file through the command prompt which I will use later in Jenkins with the batch file. Executed XML file gives me the following exceptions.

C:\Users\Vinay\workspace_n\TestNGdemo>java org.testng.TestNG testng.xml
Exception in thread "main" java.lang.NoClassDefFoundError: bsh/EvalError
        at org.testng.TestRunner.<init>(TestRunner.java:99)
        at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
nner.java:508)
        at org.testng.SuiteRunner.init(SuiteRunner.java:142)
        at org.testng.SuiteRunner.<init>(SuiteRunner.java:106)
        at org.testng.TestNG.createSuiteRunner(TestNG.java:1116)
        at org.testng.TestNG.createSuiteRunners(TestNG.java:1103)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:955)
        at org.testng.TestNG.run(TestNG.java:900)
        at org.testng.TestNG.privateMain(TestNG.java:1182)
        at org.testng.TestNG.main(TestNG.java:1146)
Caused by: java.lang.ClassNotFoundException: bsh.EvalError
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 10 more

I have used following two commands to Set class path and then run the XML file

C:\Users\Vinay\workspace_n\TestNGdemo>set classpath=C:\Users\Vinay\worksp
estNGdemo\bin;C:\Users\Vinay\workspace_n\TestNGdemo\lib\*;

C:\Users\Vinay\workspace_n\TestNGdemo>java org.testng.TestNG testng.xml

I already have testng-6.8.5.jars in my lib folder. Same testNG.xml works fine when executed in eclipse.

Please help to resolve this issue.

3
  • Check if source class path is properly added to project build path > Source. Mar 8 '17 at 18:41
  • @Md.ZishanPaya: Yes. the source class path is configured correctly.
    – iAutomate
    Mar 9 '17 at 3:17
  • Great, After long struggle above answer works for me . Added bsh-2.0b4.jar and recent testng.jar . Thanks
    – user25040
    Apr 5 '17 at 13:05
1

You must have bsh-2.0b4.jar in your lib folder too.

BTW, you should consider upgrading your TestNG version because 6.8.5 is very old.

1
  • Thanks a lot buddy. i have included the bsh-2.0b4.jar and updated TestNG to the latest. Works fine..
    – iAutomate
    Mar 12 '17 at 4:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.