{"id":557,"date":"2004-01-19T14:08:30","date_gmt":"2004-01-19T18:08:30","guid":{"rendered":"http:\/\/wordpress.cephas.net\/?p=557"},"modified":"2004-01-19T14:08:30","modified_gmt":"2004-01-19T18:08:30","slug":"ant-tomcat-manager-on-virtual-hosts","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2004\/01\/19\/ant-tomcat-manager-on-virtual-hosts\/","title":{"rendered":"Ant &amp; Tomcat Manager on virtual hosts"},"content":{"rendered":"<p>I&#8217;m kicking out a couple freelance projects using <a href=\"http:\/\/jakarta.apache.org\/struts\/\">Struts<\/a> and <a href=\"http:\/\/www.hibernate.org\/\">Hibernate<\/a> in the next couple weeks, this weekend I was fiddling with the <a href=\"http:\/\/ant.apache.org\/\">Ant<\/a> build script and I remembered <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/manager-howto.html\">Tomcat Manager App<\/a>,  which allows you to reload contexts while Tomcat is running (as well as start, stop, install etc..).  Unfortunately, the \/manager application only sees applications within the virtual host it&#8217;s running in and because I&#8217;m working with a couple different applications, I have multiple virtual hosts and I need to be able to utilize the \/manager application from each one.  <\/p>\n<p>Turns out it&#8217;s not all that hard to get the \/manager application working within a different virtual host&#8230; as long as you read the documentation very thoroughly.  It&#8217;s as simple as adding this:<br \/>\n<code><br \/>\n&lt;<a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/config\/context.html\">Context<\/a> path=\"\/manager\" debug=\"5\" docBase=\"${CATALINA_BASE}\\server\\webapps\\manager\" <b>privileged=\"true\"<\/b> \/&gt;<br \/>\n<\/code><br \/>\n(where ${CATALINA_BASE} is the absolute path to your tomcat install) to the virtual host element you have setup in server.xml (for those not experienced with Tomcat, adding a &#8216;context&#8217; is similar to adding a virtual directory in IIS, make any more sense?).  The one gotcha (in bold) is the privileged attribute.  It *must* be set to true to run the \/manager or \/admin applications in virtual host besides localhost.<\/p>\n<p>Reloading the application using Ant is a breeze, the Tomcat documenation includes an <a href=\"http:\/\/jakarta.apache.org\/tomcat\/tomcat-5.0-doc\/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant\">example build file<\/a>, in short all you need is this:<br \/>\n<code><br \/>\n&lt;property name=\"path\" value=\"\/myapp\"\/&gt;<br \/>\n&lt;property name=\"url\" value=\"http:\/\/localhost:8080\/manager\"\/&gt;<br \/>\n&lt;property name=\"username\" value=\"myusername\"\/&gt;<br \/>\n&lt;property name=\"password\" value=\"mypassword\"\/&gt;<br \/>\n&lt;taskdef name=\"reload\" classname=\"org.apache.catalina.ant.ReloadTask\"\/&gt;<br \/>\n&lt;target name=\"reload\" &gt;<br \/>\n&lt;reload<br \/>\n&nbsp;&nbsp;url=\"${url}\"<br \/>\n&nbsp;&nbsp;username=\"${username}\" password=\"${password}\"<br \/>\n&nbsp;&nbsp;path=\"${path}\"\/&gt;<br \/>\n&lt;\/target&gt;<br \/>\n<\/code><br \/>\nMake sure that you have the catalina-ant.jar file coped from {Tomcat_install}\\server\\lib\\ to your {Ant_install}\\lib.  If you are using Eclipse, go to Windows &#8211;&gt; Preferences &#8211;&gt; Ant &#8211;&gt; &#8211;&gt; Runtime &#8211;&gt; Classpath and add catalina-ant.jar to the Runtime classpath.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m kicking out a couple freelance projects using Struts and Hibernate in the next couple weeks, this weekend I was fiddling with the Ant build script and I remembered Tomcat Manager App, which allows you to reload contexts while Tomcat is running (as well as start, stop, install etc..). Unfortunately, the \/manager application only sees &hellip; <a href=\"https:\/\/cephas.net\/blog\/2004\/01\/19\/ant-tomcat-manager-on-virtual-hosts\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Ant &amp; Tomcat Manager on virtual hosts<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,12],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/557"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=557"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/557\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}