Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Aditya September 2, 2018

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

0 votes
Aditya September 2, 2018

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

Neha Chauhan March 28, 2019


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
AUG Leaders

Atlassian Community Events