tomcatrestdeploymentantmanager-app

How do I use Ant's DeployTask to deploy a Web application to Tomcat?


$ ant deploy
Buildfile: /Users/simpatico/SOLR_HOME/build.xml

deploy:

BUILD FAILED
/Users/simpatico/SOLR_HOME/build.xml:531: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2Fsolr
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
    at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalinaTask.java:228)

Total time: 2 seconds

In build.xml:

<!--http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing_Manager_Commands_With_Ant-->
  <!-- Configure properties to access the Manager application -->
  <property name="url"      value="http://localhost:8080/manager"/>
  <property name="username" value="admin"/>
  <property name="password" value="admin"/>

  <!-- Configure the custom Ant tasks for the Manager application -->
  <taskdef name="deploy"    classname="org.apache.catalina.ant.DeployTask"/>

<!-- Configure the context path for this application -->
  <property name="path"     value="solr"/>

  <target name="deploy" description="Install web application"
          >
    <deploy url="${url}" username="${username}" password="${password}"
            path="${path}" war="file:${dist}/solr.war"/>
  </target>

Both a path of /solr and solr don't work.

<tomcat-users>
    <role rolename="manager-gui"/>
    <user password="admin" roles="manager-gui,manager-script,admin" username="admin"/>
</tomcat-users>

EDIT: now it fails to deploy becauase the app already exists at path /solr

undeploy: [undeploy] OK - Undeployed application at context path /solr

deploy: [deploy] FAIL - Application already exists at path /solr

BUILD FAILED /Users/simpatico/SOLR_HOME/build.xml:532: FAIL - Application already exists at path /solr


Solution

  • If you check out the documentation page of the Manager App, you can see the main difference is the url of the script. The example uses (mind the /text part):

    <property name="url"      value="http://localhost:8080/manager/text"/>
    

    In a *nix environment you have to check what user runs the server, and if that user has the correct permissions to alter files under your web directory.