Org.testng.testngexception cannot be found using classloader | Selenium Forum
M
Posted on 02/02/2017
Hi Ashish,

I get this error where i run the Ant compile command "org.testng.testngexception cannot be found using classloader AntClassLoader[]". If read the revies in your Dounts and Discussions page but still i could not resolve it. Also i see this as error in build.xml file "
<taskdef name="testng" classpath="${test.classpath}"
classname="org.testng.TestNGAntTask" />

</target>"

1. I created a project with Maven and was compiling and running using Maven commands.
2. I wanted it to integrate with Jenkins so tried to integrate with Ant.
3. I copied the build.xml file from your training and tried to modify the jars folder. I have all the jars in "C:\Users\ashariff\.m2\repository" i changed the value. (I have all the jars within multiple folders inside the repository folder.)
<property name="ws.jars" value="C:\Users\ashariff\.m2\repository"/>
4. Then when i complie i get the above error. I am badly stuck and spent 2-3 days to figure out but could not. Could you please guide.

And

Issue 2: when i run the project using testng.xml as Testng from Eclipse i get the extent reports generated , but if i run as mvn test from command prompt i the test run but no report is generated.

Please guide on both the issue.

M
Replied on 02/02/2017

have you added testng jar files into your ant jars folder?


M
Replied on 06/02/2017

Hi Ashish,

Yes i have all the jars inside the repository folder, but the jars are inside thier repective folders.

<property name="ws.jars" value="C:\Users\ashariff\.m2\repository"/>

Test NG jars are placed in C:\Users\ashariff\.m2\repository\org\testng\testng\6.8\testng-6.8.jar

Similarly Selenium jars are placed C:\Users\ashariff\.m2\repository\org\seleniumhq\selenium


M
Replied on 06/02/2017

So i updated the testng jars path in build.xml

<taskdef name="testng" classpath="C:\Users\ashariff\.m2\repository\org\testng\testng\6.8\testng-6.8.jar"
classname="org.testng.TestNGAntTask" />

and if i compile i get these errors

[javac] C:\Selenium\Framework 2016\Hybrid Framework\CORE_HYBRID_FRAMEWORK_20
16\src\main\java\com\qtpselenium\core\hybrid\Keywords.java:5: error: package org
.testng does not exist
[javac] import org.testng.Assert;
[javac] ^


[javac] C:\Selenium\Framework 2016\Hybrid Framework\CORE_HYBRID_FRAMEWORK_20
16\src\test\java\com\qtpselenium\core\hybrid\base\baseTest.java:4: error: packag
e org.testng.annotations does not exist
[javac] import org.testng.annotations.DataProvider;
[javac] ^
[javac] 100 errors

BUILD FAILED
C:\Selenium\Framework 2016\Hybrid Framework\CORE_HYBRID_FRAMEWORK_2016\build.xml
:84: Compile failed; see the compiler error output for details.

Total time: 15 seconds


M
Replied on 06/02/2017

[quote:3uewcv25]So i updated the testng jars path in build.xml

<taskdef name="testng" classpath="C:\Users\ashariff\.m2\repository\org\testng\testng\6.8\testng-6.8.jar"
classname="org.testng.TestNGAntTask" />
[/quote:3uewcv25]

change it back in build.xml


and for ant to work with maven repo you have to use this

http://stackoverflow.com/questions/1422427/is-there-a-way-i-can-use-maven-repositories-to-add-dependencies-to-ant


M
Replied on 07/02/2017

Hi Ashish,

I changed the below
<taskdef name="testng" classpath="C:\Users\ashariff\.m2\repository\org\testng\testng\6.8\testng-6.8.jar"
classname="org.testng.TestNGAntTask" />

<taskdef name="testng" classpath="${test.classpath}"
classname="org.testng.TestNGAntTask" />
<taskdef name="testng" classname="org.testng.TestNGAntTask">

After changing i get an warning as mentioned earlier.

In the blog it mentions to add the below code in build.xml where to add these lines in build.xml.? Anywhere in build.xml i add these lines it shows an error .

please help. I am stuck with this ant task since 3 weeks and i dont understand how to configure or manipulate the ant build.xml file.

<artifact:dependencies filesetId="deps.fileset" type="jar">
<pom file="mypom.xml"/>
</artifact:dependencies>


M
Replied on 07/02/2017

can you come on skype? give me a date and time.


M
Replied on 08/02/2017

Sure.

I have sent a add request please accept it from skype id "abwasha".

I would be able to be on SKYPE on 9th feb 2017 - IST - 8.30 AM - 9.00AM or same day any time after 6.30PM IST.


M
Replied on 10/02/2017

Hi Ashish ,

Thanks for your help. The error now is fixed and ant is able compile. But if i run it simply shows the outpur in the command promt not running the code actually. And the reports shows the test cases are passed but without actually executing the code. If i run from eclipse as testng it run and executes the code. Any idea how to get this up . The purpose to have ant task is to integrate with jenkin server.