java.lang.NoClassDefFoundError while running TestNG xml file with configured ReportNG

690 Views Asked by At

I am a new to Selenium, running my first TestNG with configured ReportNG. I have performed all the following required steps. Please help with your inputs. Thanks!

  1. Added the following JARs into the project guice 3.0 Velocity 1.4 reportng 1.1.4
  2. Disabled default listeners for TestNG
  3. Added ReportNG listeners to the xml

    XML file:

After running the .xml as TestNG suite, getting the following error. The class definition looks fine...a snapshot below...

  package SeleniumProject;

  <<Import statements go here>>

     public class Test1DemoautBookTicket {

        --------
     }


Error:

java.lang.NoClassDefFoundError: org/apache/commons/collections/ExtendedProperties at org.apache.velocity.runtime.RuntimeInstance.<init> (RuntimeInstance.java:160) at org.apache.velocity.runtime.RuntimeSingleton.<clinit> (RuntimeSingleton.java:95) at org.apache.velocity.app.Velocity.setProperty(Velocity.java:117) at org.uncommons.reportng.AbstractReporter.<init>(AbstractReporter.java:62) at org.uncommons.reportng.HTMLReporter.<init>(HTMLReporter.java:83) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:50) at org.testng.TestNG.initializeConfiguration(TestNG.java:914) at org.testng.TestNG.run(TestNG.java:1022) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77) Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ExtendedProperties at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 16 more

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
   <suite name="FirstSelenium">
   <listeners>
     <listener class-name="org.uncommons.reportng.HTMLReporter"/>
     <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
   </listeners>
      <test name="Test1"> 
            <classes>
            <class name="SeleniumProject.Test1DemoautBookTicket"></class>
            </classes>
     </test>
    </suite>
1

There are 1 best solutions below

0
Fredrik K On

I downloaded the ReportNG jars from jar-download.com. Among the files was also a file named velocity-dep-1.4.jar. Before I added it to the project I got the same error as you.

(Disabling the default listeners doesn't seem necessary.)