views:

1095

answers:

2

I wish to use the Tomcat install/deploy tasks from catalina-ant.jar to deploy a webapp to a remote app server.

After installing Ant using the instructions found here, my ant folder is configured as:

/usr/local/ant

My "Ant Home" has also been set to that directory through Eclipse. I copied catalina-ant.jar to my ant/lib folder.

My build.xml contains the following:

...
<path id="catalina-ant-classpath">
  <fileset dir="${ant.home}/lib">
    <include name="catalina-ant.jar"/>
  </fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
  <classpath refid="catalina-ant-classpath"/>
</taskdef>
...

Yet my build fails with the following error:

build.xml:83: taskdef class org.apache.catalina.ant.InstallTask cannot be found

Could there be a permissions issue going on with my /usr/local/ant directory? Is there a better place to put catalina-ant.jar?

EDIT: Strangely enough, if I put the jar somewhere else (say, in a directory inside of my user folder) and change the path to it in my build.xml it works. Ideas?

+2  A: 

Eclipse cannot see the catalina-ant.jar. If it is in your ANT_HOME/lib directory, check what ANT_HOME is eclipse using.

Go to your Eclipse Preferences > Ant > Runtime and see the classpath tab to see if eclipse can see the jar. Sometimes if your ANT_HOME is pointing to the right place, you may still need to restart Eclipse after adding a jar for Eclipse to see it.

Also, I would test that you can run your build from the command line too, that might help you narrow down the issue.

Deep Kapadia
I checked the Ant > Runtime settings and all of the expected jars (including catalina-ant.jar) are present. Eclipse still can't see them after a restart, though.
Zack Mulgrew
+3  A: 

Running ant with the -debug flag also helps. It'll list out all the found jars & classpath info you'll ever need.

Nathan
Thanks for the tip. This indeed is useful.
Zack Mulgrew