ant目标将战争部署到tomcat7 / webapps

时间:2013-08-16 13:03:48

标签: java ant tomcat7 war web-deployment

我想使用*.war目标将刚刚创建的${TOMCAT_HOME}/webapps(已爆炸)部署到ant

CONFIGURATION

我的tomcat版本是7.0.37而tomcat-users.xml是:

  <role rolename="tomcat"/>
  <role rolename="role1"/>
   <role rolename="manager-gui"/>

  <user username="tomcat" password="tomcat" roles="tomcat,manager-gui"/>
  <user username="both" password="tomcat" roles="tomcat,role1,manager-gui"/>
  <user username="role1" password="tomcat" roles="role1"/>

war.properties是:

# War Build Properties

package.dir=${basedir}/package
war.exploded.dir=${deploy.dir}/war-ex
# --------- Tomcat Settings ---------------

# FIXME : tomcat.url=http://localhost:8080/manager/text
tomcat.url=http://localhost:8080/manager

tomcat.username=tomcat
tomcat.password=tomcat

context-path=/eccount

我的deploy-war目标如下(tomcat-deploy.xml):

<taskdef name="catalina-deploy"    classname="org.apache.catalina.ant.DeployTask"       classpathref="catalina.lib.classpath"/>
  <target name="deploy-war" depends="build-wardir" description="Install web app">
    <catalina-deploy url="${tomcat.url}" 
            username="${tomcat.username}" 
            password="${tomcat.password}"
            path="${context-path}" 
            localwar="file://${war.exploded.dir}"/>
  </target>

问题

当我通过命令行点击ant deploy-war时,我得到以下异常:

FileNotFoundException : http://localhost:8080/manager/deploy?path=%2Feccount&war=file%3A%2F%2FC%3A%5Ceccount%2Fdeploy%2Fwar-ex

但是,可以通过网络浏览器访问相同的路径file:///C:/eccount/deploy/war-ex

参考

Deploy A New Application Remotely in Tomcat 7.0.37

Deployment of war file on Tomcat

How Apache Ant deploys .war file to Tomcat

Catalina-Ant for Tomcat 7

1 个答案:

答案 0 :(得分:4)

嗯,问题已解决:

步骤1:更新AT7的tomcat管理器URL

 tomcat.url=http://localhost:8080/manager/text

第2步:为用户添加额外角色

  <role rolename="manager-script"/>

  <user username="tomcat" password="tomcat" roles="tomcat,manager-gui,manager-script"/>

感谢Ant Tomcat 7 Reload FileNotFoundException

相关问题