aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Failed build  : InstallTask cannot be found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Failed build  : InstallTask cannot be found" Watch "Failed build  : InstallTask cannot be found" New topic
Author

Failed build : InstallTask cannot be found

jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
I'm going through the step by step Spring MVC introduction tutorial at
http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step-Part-1.html

and have setup my environment correctly.How ever when I try just running "ant" from the springapp directory the build fails with the message :

BUILD FAILED
C:\projects_main\springapp\build.xml:78: taskdef class org.apache.catalina.ant.I
nstallTask cannot be found


Line 78 in question is :

taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath>
<path location="${appserver.home}/server/lib/catalina-ant.jar"/>
</classpath>
</taskdef>




The catalina-ant.jar is there in "${appserver.home}/server/lib/".
${appserver.home} is pointing to "C:\apache-tomcat-5.5.16"

Thanx
jeff mutonho
Mark Boicey
Greenhorn

Joined: Apr 28, 2006
Posts: 1
I had this problem on windows 2000. I got it working by changing the build.properties file. The key was using forward slash "/" for file paths which is not normal in windows.

SAMPLE build.properties file:

# Ant properties for building the springapp

appserver.home=c:/tomcat
deploy.path=c:/tomcat/webapps

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=both
tomcat.manager.password=tomcat
Sunil swain
Greenhorn

Joined: Jul 14, 2009
Posts: 10
Hi i also faced the same problem when testing the example.When i checked i saw my tomcat home was not containing any server directory.All jar files were inside lib only .So from the build script i just removed server and it worked fine.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

Mark Boicey wrote:I had this problem on windows 2000. I got it working by changing the build.properties file. The key was using forward slash "/" for file paths which is not normal in windows.


You might be interested in knowing that in almost all cases, using a forward slash in pathnames in Java is the better way to go. One of the primary reasons that that is the backslash is frequently interpreted as an escape character, and therefore will result of the formation of an actual pathname that doesn't quite match the pathname you wanted. This is especially true in java strings and properties files.

Another reason for doing this is that the forward slash is the generic path component separator for the Java File classes. If you use it, often the same code will work unchanged whether the filesystem in question is Windows, Unix, or something more esoteric.

Finally, in certain cases, Windows itself will honor forward slashes as though they were backslashes. I don't have the formal specs on that, but the primary obstacle to wider use of forward slashes in Windows pathnames is that the forward slash is used as the command-line option switch indicator (Unix uses '-'). So to avoid command-parsing issues, Windows is sort of stuck with backslash.


Customer surveys are for companies who didn't pay proper attention to begin with.
Brett Chatman
Greenhorn

Joined: Jan 15, 2011
Posts: 3
Hey I am having this same issue (I also happen to be going through the Spring tutorial).

Tomcat is located at C:/dev/apache-tomcat-7.0.5, ant is at C:/dev/ant, and my application is c:/dev/springapp.


My build.properties file looks like this:

appserver.home=C:/dev/apache-tomcat-7.0.5

appserver.lib=${appserver.home}/lib

deploy.path=${appserver.home}/webapps

tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret



And the relevant part of my build.xml file is:




but when I go to c:/dev/springapp and run the ant command, I keep getting following error:

BUILD FAILED
c:\dev\springapp\build.xml:85: taskdef class org.apache.catalina.ant.InstallTask cannot be found
using the classloader AntClassLoader[C:\dev\apache-tomcat-7.0.5\lib\catalina-ant.jar]


Which is perplexing, since C:\dev\apache-tomcat-7.0.7\lib\catalina-ant.jar is the exact path to my catalina-ant jar.


Does anyone have any idea why this might be happening???
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Welcome to CodeRanch, Brett Chatman & Mark Boicey
Brett Chatman wrote:...Does anyone have any idea why this might be happening???

Most probably a class loader issue...
Have you tried setting the catalina-ant.jar in the CLASSPATH of the environment which loads Ant?

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Brett Chatman
Greenhorn

Joined: Jan 15, 2011
Posts: 3
I agree that it probably is a classloader problem, but I have no idea what to do about it. I tried what you said, and put the catalina-ant.jar in my CLASSPATH variable ( I am running windows 7 64 bit ), but I got the same error. I also tried removing catalina-ant from tomcat's lib folder, but more of the same.

Any more suggestions/ideas would be much appreciated.

I don't know if this will be helpful or not, but my TOMCAT_HOME/lib folder looks like this:

annotations-api.jar
catalina-ant.jar
catalina-ha.jar
catalina-tribes.jar
catalina.jar
ecj-3.6.jar
el-api.jar
jasper-el.jar
jasper.jar
jsp-api.jar
servlet-api.jar
tomcat-api.jar
tomcat-coyote.jar
tomcat-dbcp.jar
tomcat-i18n-es.jar
tomcat-i18n-fr.jar
tomcat-i18n-ja.jar
tomcat-util.jar

And my ANT_HOME/lib directory looks like so:

ant-antlr.jar
ant-antlr.pom
ant-apache-bcel.jar
ant-apache-bcel.pom
ant-apache-bsf.jar
ant-apache-bsf.pom
ant-apache-log4j.jar
ant-apache-log4j.pom
ant-apache-oro.jar
ant-apache-oro.pom
ant-apache-regexp.jar
ant-apache-regexp.pom
ant-apache-resolver.jar
ant-apache-resolver.pom
ant-apache-xalan2.jar
ant-apache-xalan2.pom
ant-commons-logging.jar
ant-commons-logging.pom
ant-commons-net.jar
ant-commons-net.pom
ant-jai.jar
ant-jai.pom
ant-javamail.jar
ant-javamail.pom
ant-jdepend.jar
ant-jdepend.pom
ant-jmf.jar
ant-jmf.pom
ant-jsch.jar
ant-jsch.pom
ant-junit.jar
ant-junit.pom
ant-junit4.jar
ant-junit4.pom
ant-launcher.jar
ant-launcher.pom
ant-netrexx.jar
ant-netrexx.pom
ant-parent.pom
ant-swing.jar
ant-swing.pom
ant-testutil.jar
ant-testutil.pom
ant.jar
ant.pom
libraries.properties

I don't know if there might be two instances of the InstallTask class or something?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Two things I can think of.

First, run ant with the -v option - that should print out some more information about what it is doing. I think that will print out the JARs used in a classpath.

Second, it could very well be that while org.apache.catalina.ant.InstallTask is in catalina-ant.jar, that class relies on other classes that appear in other JARs in the tomcat lib directory. Try changing the include value to be **/*.jar.


JBoss In Action
Nilesh Nikam
Greenhorn

Joined: Nov 09, 2005
Posts: 5
Class InstallTask is deprecated & replaced by DeployTask, so later version catalina-ant.jar (tomcat set up) doesn't have class InstallTask. It's just the case of replacing InstallTask by DeployTask to see it working again. For example, following entry in build.xml in spring mvc tutorial
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>

should be replaced as

<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>
K Max
Greenhorn

Joined: Feb 15, 2011
Posts: 1
That works! Many thanks
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Welcome to CodeRanch, K Max
Brett Chatman
Greenhorn

Joined: Jan 15, 2011
Posts: 3
OMG that was it. Thank you so much! I have been completely frustrated by this for the past 2 months and had just about given up on ant/tomcat ever running on my box.

Thanks a million.
Daisy Gutierrez
Greenhorn

Joined: Mar 08, 2011
Posts: 3
I just wanted to say THANK YOU to that last VERY helpful post!! I didn't spend two months but about an hour or so looking into why I was getting that error. I tried about 4 different things - so frustrating and such a waste of time!

Thanks a ton! Changing that darn little line - <taskdef name="install" classname="org.apache.catalina.ant.DeployTask"> - did the trick for me!

I read somewhere you shouldn't mess with the classpath when dealing with ant - I believe this was on that actual ant documentation, so I was trying to avoid doing the suggestion posted earlier in the thread - and a couple yrs ago.

Well, thanks a lot!! Really appreciate it!!!


On a side note, how are we suppose to know what changed inside the jar? I mean come on, it's hard enough trying to correctly setup your environment LOL However did you find that info! Amazing! Thanks!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3829

Welcome to CodeRanch, Daisy Gutierrez
how are we suppose to know what changed inside the jar?

I'm not sure they have a separate release note as such for this other than the general Tomcat release notes (e.g: link) which doesn't say anything about the specific modifications.

One possibility: Get the source of Tomcat and look at the InstallTask.java and the Java Docs says this is deprecated and replaced by the DeployTask (I know it's bit of a work )
Pete Hawdon
Greenhorn

Joined: Jul 19, 2006
Posts: 2
Daisy Gutierrez wrote:
On a side note, how are we suppose to know what changed inside the jar? I mean come on, it's hard enough trying to correctly setup your environment LOL However did you find that info! Amazing! Thanks!


class org.apache.catalina.ant.InstallTask cannot be found
using the classloader AntClassLoader[C:\dev\apache-tomcat-7.0.5\lib\catalina-ant.jar]


I'd say this is telling you that the class org.apache.catalina.ant.InstallTask cannot be found in the jar C:\dev\apache-tomcat-7.0.5\lib\catalina-ant.jar - so just open the jar up and have a look (rename to eg C:\dev\apache-tomcat-7.0.5\lib\catalina-ant.zip and open in winzip or whatever) - if you can't see the class, chances are that you have an incompatible jar file.

So if you don't read release notes, you will at least get to know about it as soon as you try and deploy/run.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Thank You very much..Nilesh


SCJP 1.6 96%
David Brave
Greenhorn

Joined: May 20, 2010
Posts: 24
Thank you Nilesh Nikam, this also solved my problem.
Clive Flatau
Greenhorn

Joined: Sep 05, 2005
Posts: 2
Thanks from me also.

It's nice when you find a forum post that deals *exactly" with what you need.
Lighton Phiri
Greenhorn

Joined: Dec 29, 2011
Posts: 1

Nilesh Nikam wrote:Class InstallTask is deprecated & replaced by DeployTask, so later version catalina-ant.jar (tomcat set up) doesn't have class InstallTask. It's just the case of replacing InstallTask by DeployTask to see it working again. For example, following entry in build.xml in spring mvc tutorial
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>

should be replaced as

<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath"/>
</taskdef>


Thank you very much Nilesh. I had the same problem.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

Welcome to the Ranch, Lighton.


OCUP UML fundamental and ITIL foundation
youtube channel
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Vinod Maladkar,
Your post was moved to a new topic.
Gerardo Morales
Greenhorn

Joined: Jan 10, 2012
Posts: 3
The fact that InstallTask is deprecated is only the first problem you will face if you are following the tutorial at http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step-Part-1.html

I did a post listing the changes that you need to apply to follow the tutorial if you are using Tomcat 7.x and Spring 3, here is the link: http://blog.gmorales.net/2012/01/changes-on-developing-spring-framework.html

Good luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Failed build : InstallTask cannot be found