Tomcat 取消部署目标无法正常工作
我正在使用tomcat6和ant1.7.1。 在尝试oreilly的java极限编程书中的cactus一章时,我试图使用ant通过tomcat manager部署、取消部署一个web应用程序 我使用taskdefs编写了部署和取消部署目标,如下所示。。 当我运行部署目标时,代码被编译成war文件,并在C:\apache-tomcat-6.0.29\work\Catalina\localhost创建一个名为“xptest”(上下文名称)的空目录。 Ant输出此消息Tomcat 取消部署目标无法正常工作,tomcat,deployment,ant,Tomcat,Deployment,Ant,我正在使用tomcat6和ant1.7.1。 在尝试oreilly的java极限编程书中的cactus一章时,我试图使用ant通过tomcat manager部署、取消部署一个web应用程序 我使用taskdefs编写了部署和取消部署目标,如下所示。。 当我运行部署目标时,代码被编译成war文件,并在C:\apache-tomcat-6.0.29\work\Catalina\localhost创建一个名为“xptest”(上下文名称)的空目录。 Ant输出此消息 [deploy] OK - De
[deploy] OK - Deployed application at context path /xptest
但是,在运行undeploy目标时,我只收到以下消息
Buildfile: build.xml
init:
undeploy:
BUILD SUCCESSFUL
Total time: 0 seconds
当我在浏览器中检查manager appln时,我看到应用程序xptest仍然处于部署状态。只有当我单击undeploy按钮时,它才会被删除。
为什么会这样?如果有人能帮我解决这个问题,请
谢谢
标记
构建文件的相关部分如下所示
....
<property environment="env."/>
<property name="dir.build" value="build"/>
<property name="dir.src" value="src"/>
<property name="dir.resources" value="resources"/>
<property name="dir.lib" value="lib"/>
<property name="url.manager" value="http://localhost:8080/manager"/>
<property name="username.manager" value="me"/>
<property name="password.manager" value="mypasswd"/>
<property name="host" value="http://localhost"/>
<property name="port" value="8080"/>
<property name="webapp.context.name" value="xptest"/>
....
<target name="init" description="sets properties if conditions are true">
<condition property="is.tomcat.started">
<http url="${host}:${port}"/>
</condition>
<condition property="is.webapp.deployed">
<and>
<isset property="is.tomcat.started"/>
<http url="${host}:${port}/${webapp.context.name}"/>
</and>
</condition>
</target>
<target name="prepare" description="generate the cactus.properties file each time Cactus tests are run">
<mkdir dir="${dir.build}"/>
<propertyfile file="${dir.build}/cactus.properties">
<entry key="cactus.contextURL" value="${host}:${port}/
${webapp.context.name}"/>
<entry key="cactus.servletRedirectorName" value="${servlet.redirector}"/>
<entry key="jspRedirectorName" value="${jsp.redirector}"/>
<entry key="cactus.filterRedirectorName" value="${filter.redirector}"/>
</propertyfile>
</target>
<target name="compile" depends="prepare" description="Compile all source code">
<javac srcdir="${dir.src}" destdir="${dir.build}" verbose="yes">
<classpath refid="classpath.project"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="${dir.build}/${webapp.context.name}.war"
webxml="${dir.resources}/web.xml">
<classes dir="${dir.build}">
<include name="com/oreilly/javaxp/cactus/**/*.class"/>
</classes>
<lib dir="${env.CACTUS_HOME}/lib">
<include name="aspectjrt-1.5.3.jar"/>
<include name="cactus.core.framework.uberjar.javaEE.14-
1.8.1.jar"/>
<include name="commons-logging-1.1.jar"/>
<include name="httpunit-1.6.jar"/>
<include name="junit-3.8.2.jar"/>
</lib>
<fileset dir="${dir.resources}">
<include name="*.jsp"/>
<include name="*.html"/>
</fileset>
</war>
</target>
<target name="start.tomcat">
<taskdef name="starttomcat"
classname="com.oreilly.javaxp.tomcat.tasks.StartTomcatTask">
<classpath>
<path location="${dir.lib}/tomcat-tasks.jar"/>
</classpath>
</taskdef>
<starttomcat testURL="${host}:${port}" catalinaHome="${env.CATALINA_HOME}"/>
</target>
<target name="undeploy" depends="init" if="is.webapp.deployed" description="Remove web application">
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask">
<classpath>
<path location="${env.CATALINA_HOME}/lib/catalina-ant.jar"/>
</classpath>
</taskdef>
<undeploy url="${url.manager}" username="${username.manager}"
password="${password.manager}"
path="/${webapp.context.name}"/>
</target>
<target name="deploy" depends="war,start.tomcat,undeploy" description="Install web application">
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask">
<classpath>
<path location="${env.CATALINA_HOME}/lib/catalina-ant.jar"/>
</classpath>
</taskdef>
<deploy url="${url.manager}" username="${username.manager}"
password="${password.manager}"
path="/${webapp.context.name}" war="file:${dir.build}/${webapp.context.name}.war"/>
</target>
。。。。
....
我不完全确定可能出了什么问题,但似乎这可能是您检查应用程序是否已部署的条件。您可以尝试在尝试取消部署时回显设置
我还可以推荐一下上面描述的方法吗?这对我很有效。使用名为tomcat.context.status的目标执行此处描述的操作,然后可以将undeploy
目标更改为:
<target name="undeploy" depends="tomcat.context.status" unless="context.notInstalled" description="Remove web application">