0
votes

I'm inheriting a project I need to maintain and trying to get the Ant deployment to Tomcat working on my localhost. When I run the deploy task, I get the following errors:

BUILD FAILED
/.../build.xml:69: Problem: failed to create task or type deploy
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.

I've tried looking around at others having the same problem, and found that commonly issues were in relation to CLASSPATH and missing catalina-ant.jar.

I added catalina-ant.jar to a folder in my project, called lib-exec, and inside my build.xml, these jars are loaded with:

<path id="project.classpath">
    <fileset dir="${libDirectory}" includes="**/*.jar" />
    <fileset dir="${extLibDirectory}" includes="**/*.jar" />
</path>

and ${extLibDirectory} is defined as:

<property name="extLibDirectory" location="ext-lib" />

My setup is as follows:

  • MAC OS X 10.8.4
  • Tomcat 7.0.42.0 (installed via Homebrew)
  • Java 1.6.0_51
  • Apache Ant 1.8.4

I tried running the ant deploy task from the command line, and also added

export CLASSPATH=$CLASSPATH:/usr/local/Cellar/tomcat/7.0.42/libexec/lib

to *~/.bash_profile* to attempt to include catalina-ant.jar this way, but nothing seems to work.

Any ideas what I'm messing up?

1

1 Answers

1
votes

In addition to including the Tomcat classes in the Ant classpath, you need to define the "deploy" task to have Ant recognize it in the build.xml file, using the taskdef task (place it at the top of build.xml).

Defining paths and properties inside build.xml is completely irrelevant to the classpath (when build.xml is processed the JVM is already running).

Putting a folder in the classpath is likely useless (you need to include in the classpath the jar archives in that folder instead).

Moreover, there's no guarantee that Ant cares for the CLASSPATH environment variable; you have to inspect, and possibly change, the Ant launch script.