In Eclipse I am getting 5 warnings for my build.xml:
taskdef class.org.apache.catalina.ant.InstallTask cannot be found
taskdef class.org.apache.catalina.ant.
Guess you might have to do this change, since there is no more details in your question
<fileset dir="${appserver.home}/common/lib">
<include name="servlet*.jar"/>
</fileset>
I beleive you might have the above settings in your build.xml Please, change ${appserver.home} to the directory that contains the tomcat installation
<fileset dir="C:/Program Files/Apache Software Foundation/Tomcat 5.5/common/lib">
<include name="servlet*.jar"/>
</fileset>
In tomcat 7, org.apache.catalina.ant contains a set of Task that can be used to interact with the Manager application to deploy, undeploy, list, reload, start and stop web applications from a running instance of Tomcat. Replacing InstallTask with DeployTask will solve build problem.
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"/>`enter code here`
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
Try out the following, it will solve your problem:
1) Click Eclipse menu Window > Preferences
2) Click Ant > Runtime
3) Under Classpath tab, select Ant Home Entries and click button Add External JARs
4) Browse and open $ECLIPSE_HOME/plugins/org.apache.ant_myscrum/lib/catalina-ant.jar
5) Click Apply and OK button
I think only mentioning the CATALINA_HOME does not work. You need to put the catalina-ant jars to the Ant's class path. In tomcat 7, there 4 jars for this purpose while there was only single jar for this in earlier versions. Please follow this link.
As quoted from the link,
To start with, make sure Tomcat manager is configured for use by Catalina-Ant. Make sure that
manager-script
is included in the roles for one of the users inTOMCAT_HOME/conf/tomcat-users.xml
. For example:
<tomcat-users>
<user name="admin" password="s3cr£t" roles="manager-gui,manager-script"/>
</tomcat-users>
Catalina-Ant for Tomcat 6 was encapsulated within a single JAR file. Catalina-Ant for Tomcat 7 requires four JAR files. One from
TOMCAT_HOME/bin
:
tomcat-juli.jar
and three from
TOMCAT_HOME/lib
:
catalina-ant.jar
tomcat-coyote.jar
tomcat-util.jar
There are at least three ways of making the JARs available to Ant:
- Copy the JARs into the
ANT_HOME/lib
folder. Then Ant will just find them.- Copy the JARs to a folder within your project that you check into your source control system. Ant then needs a path id to find them:
<path id="catalina-ant-classpath">
<fileset dir="${catalina-ant-dir}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
<include name="tomcat-juli.jar"/>
</fileset>
</path>
Where
catalina-ant-dir
is the directory with the JARs in. This way you don’t need to modify the Ant installation on every machine you build on. Access the JARs directly from your Tomcat 7 installation. Ant then needs a path id to find them:
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"/>
<include name="tomcat-coyote.jar"/>
<include name="tomcat-util.jar"/>
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar"/>
</fileset>
</path>
Where appserver.lib is the path to Tomcat 7’s lib directory and
appserver.home
is the path to Tomcat’s top level installed directory. This way Tomcat 7 is required on every box you build on.My personal preference is for 2 above.
Now that your Ant script can see the Catalina-Ant JARs you need to tell it what tasks are available. These are most if not all of the tasks that are available to Ant.
<taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-findleaks" classname="org.apache.catalina.ant.FindLeaksTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/>
<taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/>
Finally you need a set of tasks that actually do the work. Although, as you can see above, there are a few tasks I only tend to use the following ones:
<target name = "stop-webapp">
<catalina-stop url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"
failonerror="false"/>
</target>
<target name = "start-webapp">
<catalina-start url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"/>
</target>
<target name = "undeploy-webapp">
<catalina-undeploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"
failonerror="false"/>
</target>
<target name = "deploy-webapp">
<catalina-deploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"
war="file:${war.file}"/>
</target>
tomcat.manager.url
is the URL where Tomcat manager lives. This is another of the changes from Tomcat 6 to Tomcat 7. Usually this will be:http://:8080/manager/text
.
Tomcat.username
andTomcat.password
are the user name and password for Tomcat manager.
webapp.name
is the name of the Tomcat application that you are deploying.
war.file
is the path the Tomcat application you are deploying’s WAR file.
If you are using eclipes then you need to change your ant_home location by following below steps, navigate to window>prefrances>Ant>runtime>classpath>AntHome click on anthome button and provide your anthome directory path.
and to solv ur problem u need to copy catalina-ant.jar inside anthome/lib folder
Thanks, Sharad
In tomcat 7 InstallTask is replaced by DeployTask.
change your declaration like
old
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
with
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>