Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Atlassian Bamboo Logs: [testng] Cannot find class in classpath: com.vaannila.domain.UserTest

Hi Everyone


I was trying to build a sample war file and deploy it on a tomcat server. But, I'm facing this error of testNG unable to find class in the classpath. But I am pretty sure I have mentioned the right class path.

Here is my testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "" >
<suite name="User Registration suite 1" verbose="1" >
  <test name="Regression suite 1" >
      <class name="com.vaannila.domain.UserTest"/>

Here is my class:

package com.vaannila.domain;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
//Java imports
import java.util.concurrent.TimeUnit;
import java.util.List;

public class UserTest {
    private WebDriver driver;
    private String baseUrl;


Here is my build.xml file:

<?xml version="1.0" ?>
<project name="UserRegistrationAnt" default="war" basedir="." xmlns:sonar="antlib:org.sonar.ant">

    <!-- Beginning of project dir definition -->
    <property name="testng.xml.file" value="testng.xml" />
    <property name="basedir" location="." />
    <property name="src" location="${basedir}/src" />
    <property name="lib" location="${basedir}/WebContent/WEB-INF/lib" />
    <property name="build" location="${basedir}/target/classes" />
    <property name="war-file" location="${basedir}/dist" />
    <property name="test-reports" location="{basedir}/test-reports" />
    <!-- End of project dir definition -->
    <!-- Beginning of sonar properties definition -->
    <property name="" value="" />
    <property name="sonar.projectKey" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectName" value="9bc89a6e0d659c33ef4b61b27dc486b1f9075241" />
    <property name="sonar.projectVersion" value="1.0" />
    <property name="sonar.language" value="java" />
    <property name="sonar.sources" value="${src}" />
    <property name="" value="${build}" />
    <property name="sonar.sourceEncoding" value="UTF-8" />
    <!-- End of sonar properties definition -->

    <!-- Definition of external dependencies location -->
    <path id="compile.classpath">
        <fileset dir="${lib}">
                        <include name="*.jar"/>

    <!-- Making dirs for compiled, war file and test reports-->
        <target name="init">
        <mkdir dir="${build}"/>
        <mkdir dir="${war-file}" />
        <mkdir dir="${test-reports}" />

    <!-- Compilation of our source and test code -->
        <target name="compile" depends="init" >
        <javac destdir="${build}" debug="true" srcdir="${src}" classpathref="compile.classpath" includeantruntime="false" />

    <!-- Execution of testng -->
    <taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="compile.classpath" />
    <target name="tests" depends="compile">
        <testng outputdir="${test-reports}" classpathref="compile.classpath" haltOnFailure="true">
            <classpath location="{build}" />
            <xmlfileset dir="${basedir}" includes="${testng.xml.file}" />

    <!-- Execution of sonar analysis -->
    <target name="sonar" depends="compile">
        <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
            <!-- update the following line or put sonar-ant-task-*.jar in $ANT_HOME/.ant/lib folder -->
            <classpath path="/opt/ant/apache-ant-1.10.5/lib/sonarqube-ant-task-2.5.jar" />
        <!-- Execute SonarQube scanner for ant analysis -->
        <sonar:sonar />

        <target name="war" depends="compile">
        <war destfile="{war-file}/AntExample.war" webxml="WebContent/WEB-INF/web.xml">
            <fileset dir="${basedir}/WebContent"/>
            <lib dir="${lib}"/>
            <classes dir="${build}"/>

        <!--target name="clean">
                <delete dir="dist" />
                <delete dir="build" />
                <delete dir="reports" />

    <target name="all" depends="init, compile, tests, sonar, war" description="one single target to fire up every ant build stage" />


I am completely blank about this error, and have referred this link but my builds are happening without a glitch in eclipse IDE and cmd.exe. The build is failing in Atlassian bamboo CI server with the aforementioned error. So that issue and mine are completely different. I can't clean and do a build in a CI server.

Should I place testng jar in ANT_HOME/lib folder? Will that resolve this issue?

I need help on resolving this error.



1 answer

It was a silly mistake on my end. I didn't insert $ before {build} in tests target.


I am getting the same error when I run my tests from bamboo. Tried few options but not able to resolve it.

Could you please help?..I am stuck and need help immediately.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

186 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you