Thursday, December 16, 2010

"Problem: failed to create task or type for" when running Ant

Problem:

My Ant build script had the following:
<loadfile property="allprocesses" srcFile="${someFile}"/>
<for list="${allprocesses}" param="processName" delimiter="${line.separator}">
  <sequential>
    <echo>${processName}</echo>
  </sequential>
</for>
What this does is load some file, and loop through each line in the file.

However, I was getting the following error even though the code is correct:
BUILD FAILED
/home/oracle/scripts/deploy/build.xml:20: Problem: failed to create task or type for
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
Solution:

1. Add "ant-contrib-1.0b3.jar" to your $ANT_HOME/lib directory.

2. Add the following to the top of your build.xml file:
<taskdef resource="net/sf/antcontrib/antlib.xml" >
  <classpath>
    <pathelement location="${antcontrib}" />
  </classpath>
</taskdef>

8 comments:

  1. thanks! this worked perfectly

    ReplyDelete
  2. i did this and im still getting the same error is there something wrong im doign

    ant home C:\hudson\tools\AntTest\lib in this path i added the ant-contrib-1.0b3.jar file

    and then added this to my build file







    im using ant 1.8.2 i also add this property to my build.xml file



    could you please help me on this?

    ReplyDelete
  3. i did this and im still getting the same error is there something wrong im doign

    ant home C:\hudson\tools\AntTest\lib in this path i added the ant-contrib-1.0b3.jar file

    and then added this to my build file

    taskdef resource="net/sf/antcontrib/antcontrib.properties"
    classpath
    pathelement location="${antcontrib}" /
    /classpath
    /taskdef

    im using ant 1.8.2 i also add this property to my build.xml file

    property name="antcontrib" value="/path/to/jar" /

    could you please help me on this?

    i remove all the "<" and ">" because the text did not appear

    ReplyDelete
  4. i also tried with

    taskdef resource="net/sf/antcontrib/antlib.xml"

    ReplyDelete
  5. Try checking out my Ant scripts that I just published. They should work for you.

    http://blog.ipnweb.com/2011/05/ant-scripts-for-oracle-soa-suite-11g.html

    ReplyDelete
  6. thanks alot ..it worked for me ...awesome. ..ta ta ta

    ReplyDelete
  7. I have same problem. I am using Ant 1.8.2 and i tried
    taskdef resource="net/sf/antcontrib/antlib.xml"

    and taskdef resource="net/sf/antcontrib/antcontrib.properties"

    but not worked. After this, i realize ant-contrib-1.0b3.jar is not supported Ant version 1.6 or later. I must use ccp-contrib but how? I don't know. Please help.

    Regards.

    ReplyDelete
  8. Mr. Anonymous :

    There could be a chance that ant-contrib-1.0b5-SNAPSHOT.jar(any versions) is missing in lib folder. Try adding that to /lib/ folder it will solve ur issue. I know its been years that you faced this issue, I have faced this issue just know and fixed it by doing so like above. Writing this comment will help others in future.

    Thank You.

    ReplyDelete