我使用Tomcat 6,Apache Ant的1.7.1和JDK 1.6的OS X雪豹...問題與取消部署任務到Tomcat 6
創建以下構建腳本和配套屬性文件:
(1)的build.xml
<?xml version="1.0"?>
<project name="${project.name}" default="deploy" basedir=".">
<property file="build.properties"/>
<property file="admin.properties"/>
<taskdef file="tomcatTasks.properties">
<classpath>
<pathelement path="${tomcat.home}/lib/catalina-ant.jar"/>
</classpath>
</taskdef>
<target name="prepare">
<mkdir dir="${webapp.build.dir}" />
<mkdir dir="${webapp.build.dir}/WEB-INF" />
<mkdir dir="${webapp.build.dir}/WEB-INF/lib" />
<mkdir dir="${webapp.build.dir}/WEB-INF/classes" />
</target>
<target name="static" depends="prepare">
<!-- Copy web files -->
<copy todir="${webapp.build.dir}/">
<fileset dir="web" />
</copy>
<!-- Copy webapp configuration files -->
<copy todir="${webapp.build.dir}/WEB-INF/">
<fileset dir="etc" />
</copy>
<!-- Copy properties files -->
<copy todir="${webapp.build.dir}/WEB-INF/classes">
<fileset dir="props" />
</copy>
<!-- Copy jar files -->
<copy todir="${webapp.build.dir}/WEB-INF/lib/">
<fileset dir="lib" />
</copy>
</target>
<target name="compile" depends="static">
<javac srcdir="src"
destdir="${webapp.build.dir}/WEB-INF/classes/"
deprecation="off" debug="on" optimize="off">
<classpath>
<!-- Include all JAR files in my local library -->
<fileset dir="lib">
<include name="*.jar"/>
</fileset>
<!-- Include all common libraries in Tomcat -->
<fileset dir="${tomcat.home}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="deploy" depends="compile">
<jar jarfile="${build.dir}/${webapp.name}.war" basedir="${webapp.build.dir}" />
<!-- Copy the newly built WAR file into the deployment directory -->
<copy file="${build.dir}/${webapp.name}.war" todir="${tomcat.deployment.dir}" />
</target>
<target name="clean" description="Clears all generated files, including build directories, distributables, and documentation.">
<delete dir="${build.dir}"/>
</target>
<target name="package">
<jar jarfile="${build.dir}/${webapp.name}.war" basedir="${webapp.build.dir}" />
</target>
<target name="install" description="Install application in Tomcat" depends="package">
<deploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"
war="file:${tomcat.deployment.dir}/${webapp.name}.war"/>
</target>
<target name="undeploy" depends="clean" description="Remove application in Tomcat">
<undeploy url="${tomcat.manager.url}"
username="${tomcat.username}"
password="${tomcat.password}"
path="/${webapp.name}"/>
</target>
</project>
(2)admin.properties:
tomcat.server=localhost
tomcat.manager.url=http://${tomcat.server}:8080/manager
tomcat.username=admin
tomcat.password=admin
(3)的build.properties:
project.name=myproject
build.dir=./build
# Web app properties for the project
webapp.name=myproject
webapp.build.dir=${build.dir}/${webapp.name}
webapp.virtual.host=localhost
webapp.meta.dir=${webapp.build.dir}/META-INF
# Tomcat properties
tomcat.home=/Users/myuser/DevTools/Java/tomcat/apache-tomcat-6.0.20
tomcat.deployment.dir=${tomcat.home}/webapps
(4)tomcatTasks.properties:
# Tomcat Task Properties
deploy=org.apache.catalina.ant.DeployTask
install=org.apache.catalina.ant.InstallTask
list=org.apache.catalina.ant.ListTask
reload=org.apache.catalina.ant.ReloadTask
remove=org.apache.catalina.ant.RemoveTask
resources=org.apache.catalina.ant.ResourcesTask
roles=org.apache.catalina.ant.RolesTask
start=org.apache.catalina.ant.StartTask
stop=org.apache.catalina.ant.StopTask
undeploy=org.apache.catalina.ant.UndeployTask
(5)的Tomcat-users.xml中:
當我運行部署目標,一切工作(它把myproject.war)$ CATALINA_HOME/webapps中下...
然而,當我運行取消部署的目標,我得到的以下錯誤消息:
問題:
Buildfile: /Users/myuser/work/myproject/build.xml
Trying to override old definition of datatype resources
clean:
[delete] Deleting directory /Users/myuser/work/myproject/build
undeploy:
BUILD FAILED
/Users/myuser/work/myproject/build.xml:83: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/undeploy?path=/myproject
Total time: 170 milliseconds
會很感激,如果有人可以告訴我什麼,我做錯了......
感謝您在百忙之中閱讀本文時...
快樂編程。
我認爲你的意思是: –
2010-08-26 20:45:44
編輯它以包含您的修復程序。 – Chucky 2013-06-05 11:24:22