的taskdef类org.apache.catalina.ant.InstallTask无法找到 [英] taskdef class org.apache.catalina.ant.InstallTask cannot be found
问题描述
在Eclipse中我收到5警告我的build.xml:
的taskdef class.org.apache.catalina.ant.InstallTask无法找到
的taskdef class.org.apache.catalina.ant.ListTaskcannot发现
的taskdef class.org.apache.catalina.ant.ReloadTaskcannot发现
的taskdef class.org.apache.catalina.ant.StartTask无法找到
的taskdef class.org.apache.catalina.ant.StopTask无法找到
我已经成立了以下系统环境变量(Windows 7中)
ANT_HOME:C:\\ Apache的ANT-1.8.4
CATALINA_HOME:C:\\ Apache的Tomcat的7.0.29
JAVA_HOME:C:\\ Program Files文件\\的Java \\ jdk1.6.0_34
并增加ANT_HOME%%/ bin添加到PATH
编辑:我还添加卡塔利娜-的ant.jar到C:\\ Apache的ANT-1.8.4 \\ lib中
在code的多个部分:
<! - 我们需要卡塔利娜罐子为Tomcat - >
<! - *为其他应用服务器 - 检查文档 - >
<文件集DIR =$ {} appserver.lib>
<包括姓名=卡塔利娜-的ant.jar/>
< /文件集>
< /路径><的taskdef NAME =安装类名=org.apache.catalina.ant.InstallTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =重载类名=org.apache.catalina.ant.ReloadTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =清单类名=org.apache.catalina.ant.ListTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =启动类名=org.apache.catalina.ant.StartTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
<的taskdef NAME =停止类名=org.apache.catalina.ant.StopTask>
<类路径REFID =卡特琳娜 - 蚂蚁类路径/>
< /&的taskdef GT;
怎么了?
我觉得只有提CATALINA_HOME不起作用。你需要把卡塔利娜蚂蚁罐到Ant的类路径。在Tomcat中7,有4罐为此,虽然有在早期版本这只单独的jar。请按照此链接。
如从链路引述
首先,要确保Tomcat管理配置为使用的
卡特琳娜 - 蚂蚁。确保管理脚本
包含在角色
在用户之一TOMCAT_HOME / conf目录/ tomcat的-users.xml中
。对于
例如:
块引用>< tomcat的用户>
<使用者名称=admin的密码=s3cr£T角色=经理桂,经理脚本/>
< / tomcat的用户>
卡特琳娜 - 蚂蚁为Tomcat 6的一个JAR文件中封装。
卡特琳娜 - 蚂蚁为Tomcat 7需要四个JAR文件。一位来自
TOMCAT_HOME / bin中
:
块引用>Tomcat的juli.jar
和三位来自
TOMCAT_HOME / lib目录
:
块引用>卡塔利娜-的ant.jar
Tomcat的coyote.jar
Tomcat的util.jar
有使现有的JAR文件到Ant的至少在三个方面:
- JAR文件复制到
ANT_HOME / lib目录
文件夹中。 Ant将只是找到他们。
- JAR文件复制到您签入您的源代码控制系统项目内的文件夹。蚂蚁则需要一个路径ID找到他们:
块引用><路径ID =卡特琳娜 - 蚂蚁类路径>
<文件集DIR =$ {卡特琳娜-ANT-DIR}>
<包括姓名=卡塔利娜-的ant.jar/>
<包括姓名=Tomcat的coyote.jar/>
<包括姓名=的tomcat-util.jar/>
<包括姓名=Tomcat的juli.jar/>
< /文件集>
< /路径>
其中,
卡塔利娜-ANT-DIR
是。这方式JAR文件的目录,你
并不需要修改你每次构建的机器上安装蚂蚁
上。直接从你的Tomcat 7的安装访问的JAR。然后蚂蚁
需要一个路径ID找到他们:
块引用><路径ID =卡特琳娜 - 蚂蚁类路径>
<文件集DIR =$ {} appserver.lib>
<包括姓名=卡塔利娜-的ant.jar/>
<包括姓名=Tomcat的coyote.jar/>
<包括姓名=的tomcat-util.jar/>
< /文件集>
<文件集DIR =$ {} appserver.home / bin中>
<包括姓名=Tomcat的juli.jar/>
< /文件集>
< /路径>
在哪里appserver.lib是路径到Tomcat 7的lib目录,
appserver.home
是路径到Tomcat的顶层安装目录。
这样的Tomcat 7,需要在每个盒子你建立的。
我个人的preference是大于2。
现在,您的Ant脚本可以看到你所需要的卡特琳娜 - 蚂蚁JAR来
告诉它什么任务都可用。这些大部分如果不是全部都是的
可用到Ant任务。
块引用><的taskdef NAME =卡特琳娜部署类名=org.apache.catalina.ant.DeployTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜清单类名=org.apache.catalina.ant.ListTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜重载类名=org.apache.catalina.ant.ReloadTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜 - findleaks时类名=org.apache.catalina.ant.FindLeaksTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜资源类名=org.apache.catalina.ant.ResourcesTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜启动类名=org.apache.catalina.ant.StartTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜一站式类名=org.apache.catalina.ant.StopTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
<的taskdef NAME =卡特琳娜 - 取消部署类名=org.apache.catalina.ant.UndeployTaskclasspathref =卡特琳娜 - 蚂蚁类路径/>
最后,您需要一组实际上做的工作任务。虽然,你可以在上面看到,有几个任务,我只倾向于使用以下物质:
块引用><目标名称=止webapp的>
<卡塔利娜一站式URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.username
密码=$ {} tomcat.password
PATH =/ $ {} webapp.name
failonerror =FALSE/>
< /目标与GT;<目标名称=启动web应用>
<卡塔利娜启动URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.username
密码=$ {} tomcat.password
PATH =/ $ {} webapp.name/>
< /目标与GT;<目标名称=取消部署-webapp的>
<卡特琳娜 - 取消部署URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.username
密码=$ {} tomcat.password
PATH =/ $ {} webapp.name
failonerror =FALSE/>
< /目标与GT;<目标名称=部署-webapp的>
<卡塔利娜部署URL =$ {} tomcat.manager.url
用户名=$ {} tomcat.username
密码=$ {} tomcat.password
PATH =/ $ {} webapp.name
战争=文件:$ {} war.file/>
< /目标与GT;
tomcat.manager.url
是URL Tomcat管理生活的地方。这是
另一个变化从Tomcat 6到Tomcat 7。通常这将
是:的http://:8080 /经理/文
Tomcat.username
和Tomcat.password
是用户名和密码
为Tomcat经理。
webapp.name
是Tomcat应用程序,你是名
部署。
war.file
是Tomcat应用程序要部署的WAR的路径
文件中。
块引用>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.ListTaskcannot be found taskdef class.org.apache.catalina.ant.ReloadTaskcannot be found taskdef class.org.apache.catalina.ant.StartTask cannot be found taskdef class.org.apache.catalina.ant.StopTask cannot be found
I've set up the following system environment variables (Windows 7)
ANT_HOME: C:\apache-ant-1.8.4 CATALINA_HOME: C:\apache-tomcat-7.0.29 JAVA_HOME: C:\Program Files\Java\jdk1.6.0_34 and have added %ANT_HOME%/bin to PATH
edit: I've also added catalina-ant.jar into C:\apache-ant-1.8.4\lib
More parts of the code:
<!-- We need the Catalina jars for Tomcat --> <!-- * for other app servers - check the docs --> <fileset dir="${appserver.lib}"> <include name="catalina-ant.jar"/> </fileset> </path> <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath refid="catalina-ant-classpath"/> </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>
What's wrong?
解决方案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.
这篇关于的taskdef类org.apache.catalina.ant.InstallTask无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!