无法找到taskdef类org.apache.catalina.ant.InstallTask [英] taskdef class org.apache.catalina.ant.InstallTask cannot be found
问题描述
在Eclipse中,我的build.xml有5个警告:
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
我设置了以下系统环境变量(Windows 7)
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
编辑:我还添加了catalina-ant .jar into C:\apache-ant-1.8.4\lib
edit: I've also added catalina-ant.jar into C:\apache-ant-1.8.4\lib
更多部分代码:
<!-- 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>
有什么问题?
推荐答案
我认为只提到CATALINA_HOME不起作用。你需要把蚂蚁的罐子放在蚂蚁的路上。在tomcat 7中,有4个jar为此目的,而在早期版本中只有单个jar。请按照链接。
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.
从链接引用
首先,确保Tomcat管理器已配置为使用
Catalina-Ant。确保TOMCAT_HOME / conf / tomcat-users.xml中的一个用户的角色
中包含manager-script
/ code>。对于
示例:
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封装在单个JAR文件中。
Catalina-Ant对于Tomcat 7需要四个JAR文件。一个来自
TOMCAT_HOME / bin
:
tomcat-juli.jar
code> TOMCAT_HOME / lib :
catalina-ant.jar
tomcat-coyote.jar
tomcat-util.jar
至少有三种可用于Ant的JAR的方法:
There are at least three ways of making the JARs available to Ant:
- 将JAR复制到
ANT_HOME / lib
文件夹。然后Ant将只找到它们。 - 将JAR复制到您检入到源代码管理系统的项目中的文件夹。 Ant然后需要一个路径ID来找到它们:
- 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>
其中
catalina-ant-dir
是JAR的目录。这样你
不需要修改每个你创建
的机器上的Ant安装。直接从您的Tomcat 7安装中访问JAR。蚂蚁然后
需要一个路径id来找到它们:
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>
其中appserver.lib是Tomcat 7的lib目录和
appserver.home
是Tomcat顶级安装目录的路径。
这样,您每个建立的盒子都需要Tomcat 7。
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.
我的个人偏好是2以上。
My personal preference is for 2 above.
现在,您的Ant脚本可以看到Catalina-Ant JAR,您需要
告诉它可用的任务。这些是大部分(如果不是全部)
任务可用于Ant。
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
是Tomcat经理生活的URL。这是
从Tomcat 6到Tomcat 7的另一个更改。通常这将
为:http://:8080 / manager / text
。
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
和 Tomcat.password
Tomcat管理员的用户名和密码
。
Tomcat.username
and Tomcat.password
are the user name and password
for Tomcat manager.
webapp.name
是Tomcat应用程序的名称你是
部署。
webapp.name
is the name of the Tomcat application that you are
deploying.
war.file
是您正在部署的Tomcat应用程序的WAR
文件。
war.file
is the path the Tomcat application you are deploying’s WAR
file.
这篇关于无法找到taskdef类org.apache.catalina.ant.InstallTask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!