When using Ant builder to restart Tomcat 7 server I came across the following error:
Tried to use command /reload via a GET request but POST is required
Here is a piece of code from Ant builder script:
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" />
</target>
With a new Tomcat 7 a very special role (called “manager-script”) is required to run GET commands. Regular web based “manager” application allows POST commands only. Therefore, we need to bind “manager-script” to a user at hand.
<tomcat-users> <user name="user" password="password" roles="admin-gui,manager-gui,manager-script" /> </tomcat-users>
Note, that we don’t need to specify roles like before. Roles are predefined by default .
In addition, note that a new Tomcat manager URL is as follows:
tomcat.manager.url=http://localhost:8080/manager/text
Thank you very much, very helpful.