hell_storm2004
hell_storm2004

Reputation: 1605

Ant TaskDef Fails in ClassLoader

I am trying to define a taskdef in ant for Tomcat.

<taskdef name="antStartServer" classname="org.apache.catalina.ant.StartTask" />
<taskdef name="antStopServer" classname="org.apache.catalina.ant.StopTask" />

But when I run the script, I get the error:

taskdef class org.apache.catalina.ant.StartTask cannot be found using the classloader AntClassLoader[]

Can you please tell me what I am doing wrong? I have all the jars put in the Tomcat lib folder. I am using Tomcat 9 and Ant 1.10.5

Upvotes: 0

Views: 672

Answers (1)

Lolo
Lolo

Reputation: 4347

You need to specify a classpath in which Ant can find the classes you need:

<!-- set the path to Tomcat root install directory -->
<property name="tomcat.home" value="..."/>

<path id="tomcat.path">
  <fileset dir="${tomcat.home}/lib" includes="*.jar"/>
</path>

<taskdef name="antStartServer" classname="org.apache.catalina.ant.StartTask" classpathref="tomcat.path"/>
<taskdef name="antStopServer" classname="org.apache.catalina.ant.StopTask" classpathref="tomcat.path"/>

Upvotes: 2

Related Questions