4
$ 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

informatik01
  • 16,038
  • 10
  • 74
  • 104
simpatico
  • 10,709
  • 20
  • 81
  • 126
  • does the user admin/admin have the correct roles configured in tomcat-users.xml to acces the management interface? – csupnig May 04 '11 at 08:33
  • @simpatico: 403 means "Forbidden", are you sure you provide correct credentials? BTW, what version of Tomcat is used (is it 5.5)? – barti_ddu May 04 '11 at 08:51
  • @barti_ddu - tomcat 7. I've provided the credentials on both sides in the q (admin/admin) – simpatico May 04 '11 at 08:53
  • @simpatico: afair, for tc7 deployment url looks like `http://host:port/manager/text/deploy?path=/foo` – barti_ddu May 04 '11 at 08:58
  • for some reason SO won't show a part i've added to the question which shows the modified deploy and undeploy targets – simpatico May 04 '11 at 09:14

2 Answers2

3

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.

vbence
  • 20,084
  • 9
  • 69
  • 118
  • @vbence - you nailed it (I was looking at 5.5 that google gave). Now however it doesn't deploy becasue the app is already deployed, as shown in Q edit. – simpatico May 04 '11 at 09:11
  • @simpatico just copy-paste the **undeploy** task from the documentation. – vbence May 04 '11 at 09:19
  • @vbence - that's what i did, and modified the deploy to depend on undeploy – simpatico May 04 '11 at 09:22
  • @simpatico I guess you "deployed" your application by hand (not thru the Manager App). Try deleting it by hand and then making the initial deployment thru `ant`. After that you must be able to *undeploy* it. – vbence May 04 '11 at 09:24
  • @vbence - nope, undeployed by hand.. then ant deploy it works (since there's nothing to undeploy) but ant deploy again will give the error – simpatico May 04 '11 at 09:28
  • @simpatico You can not deploy two times in a row. You have to undeploy to be able to deploy again. – vbence May 04 '11 at 10:43
  • @vbence - yes, but every deploy is preceeded by an undeploy, which even reports success. – simpatico May 04 '11 at 10:45
  • @simpatico Interesting.. try separating them to different tasks. – vbence May 04 '11 at 11:26
  • @vbence - what I've found out is that ant undeploy deletes the app from webapps but then it reappears immediately..what might be going on? – simpatico May 04 '11 at 18:49
  • the issue is that I had under $CATALINA_HOME/conf/Catalina/localhost a solr.xml that deployed the app automatically. – simpatico May 05 '11 at 11:33
0
<target name="tomcatdeploy" description="Install web application"  >
    <deploy_tomcat url="${admin.url}" username="${admin.name}" password="${admin.password}" path="/${webapp}" war="file:${dropoff.warfile.dir}/${webapp}.war"/>
</target>

 <target name="check-context">
    <available file="${app.base.dir}/${webapp}.war" property="context.present"/>
</target>

<target name="undeploy" depends="check-context" if="context.present" description="Remove web application" >
   <undeploy_tomcat   url="${admin.url}" username="${admin.name}" password="${admin.password}" path="/${webapp}"/>
</target> 

First call "undeploy" then "tomcatdeploy" ant tasks. You have to provide ${pamram} values as necessary. "undeploy" task will check if given war file exists in the webapps directory, if so it will do actual un-deploying.

Don Srinath
  • 1,565
  • 1
  • 21
  • 32