BuildException when executing Ant task

11,918

Solution 1

I had this error and found it was caused by having an older version of ant.jar in the classpath.

Solution 2

One possibility is you may have another version of ant installed on your system and your PATH pointing to it.

Check what is ANT_HOME set to.

Run ant -version and see if it shows up 1.8.1

Solution 3

Add the following config in ~/.bashrc

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

Don't forget source ~/.bashrc

Hope useful for you!

Solution 4

you have duplicate ant in your environment.

My case was: I am using 1.9.7 ant, but ant -version gave me 1.7.1 I installed weblogic and it has 1.7.1 ant, after rename MW_HOME, the issue was gone.

I found this while I was using 1.7.1 to test junit. it shows a warning.

junit:
    [junit] WARNING: multiple versions of ant detected in path for junit
    [junit]          jar:file:/D:/wls12120/oracle_common/modules/org.apache.ant_1.7.1/lib/ant.jar!/org/apache/tools/ant/
Project.class
    [junit]      and jar:file:/D:/apache-ant-1.7.1/lib/ant.jar!/org/apache/tools/ant/Project.class
    [junit] Running HelloWorldTest
Share:
11,918
Anto
Author by

Anto

click here to edit

Updated on June 12, 2022

Comments

  • Anto
    Anto almost 2 years

    I have installed Apache Ant and set the correctly the Path, CLASS_PATH and ANT_PATH variables. When I run a jar task in a command line within my project folder where the build.xml file is, I get the following error:

    BUILD FAILED
    
    C:\Documents and Settings\TonyS\My Documents\My Workspace\code\build.xml: 32:
    
    The following error occurred while executing this line:
    jar:file:/C:/Documents%20and%20Settings/TonyS/My%20Documents/Ant/apache-ant-1.8.1/lib/ant.jar!org/apache/tools/ant/antlib.xml:37: Could not create task or type: componentdef.
    
    Ant could not find the task or a class this task relies upon.