ant target to deploy war to tomcat7/webapps

2019-05-21 03:38发布

I want to deploy the just created *.war (exploded) to ${TOMCAT_HOME}/webapps using ant target.

CONFIGURATION

My tomcat version is 7.0.37 and tomcat-users.xml is :

  <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 is :

# 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

My deploy-war target is as follows (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>

PROBLEM

When I hit ant deploy-war via command line , I get the following exception :

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

But, the same path file:///C:/eccount/deploy/war-ex is accesible via web browser.

REFERENCES

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条回答
放荡不羁爱自由
2楼-- · 2019-05-21 03:50

Well, the issue is fixed :

STEP 1 : update tomcat manager url for AT7

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

STEP 2 : add extra role to user

  <role rolename="manager-script"/>

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

Thanks to Ant Tomcat 7 Reload FileNotFoundException

查看更多
登录 后发表回答