Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think only mentioning the CATALINA_HOME does not work. You need to put the catalina-ant jars to the Ant's class path. In tomcat 7, there 4 jars for this purpose while there was only single jar for this in earlier versions. Please follow this <a href="http://paulgrenyer.blogspot.in/2011/11/catalina-ant-for-tomcat-7.html" rel="noreferrer">link</a>.</p> <p>As quoted from the link,</p> <blockquote> <p>To start with, make sure Tomcat manager is configured for use by Catalina-Ant. Make sure that <code>manager-script</code> is included in the roles for one of the users in <code>TOMCAT_HOME/conf/tomcat-users.xml</code>. For example:</p> </blockquote> <pre><code>&lt;tomcat-users&gt; &lt;user name="admin" password="s3cr£t" roles="manager-gui,manager-script"/&gt; &lt;/tomcat-users&gt; </code></pre> <blockquote> <p>Catalina-Ant for Tomcat 6 was encapsulated within a single JAR file. Catalina-Ant for Tomcat 7 requires four JAR files. One from <code>TOMCAT_HOME/bin</code>:</p> </blockquote> <pre><code>tomcat-juli.jar </code></pre> <blockquote> <p>and three from <code>TOMCAT_HOME/lib</code>:</p> </blockquote> <pre><code>catalina-ant.jar tomcat-coyote.jar tomcat-util.jar </code></pre> <blockquote> <p>There are at least three ways of making the JARs available to Ant:</p> <ul> <li>Copy the JARs into the <code>ANT_HOME/lib</code> folder. Then Ant will just find them.</li> <li>Copy the JARs to a folder within your project that you check into your source control system. Ant then needs a path id to find them:</li> </ul> </blockquote> <pre><code>&lt;path id="catalina-ant-classpath"&gt; &lt;fileset dir="${catalina-ant-dir}"&gt; &lt;include name="catalina-ant.jar"/&gt; &lt;include name="tomcat-coyote.jar"/&gt; &lt;include name="tomcat-util.jar"/&gt; &lt;include name="tomcat-juli.jar"/&gt; &lt;/fileset&gt; &lt;/path&gt; </code></pre> <blockquote> <p>Where <code>catalina-ant-dir</code> is the directory with the JARs in. This way you don’t need to modify the Ant installation on every machine you build on. Access the JARs directly from your Tomcat 7 installation. Ant then needs a path id to find them:</p> </blockquote> <pre><code>&lt;path id="catalina-ant-classpath"&gt; &lt;fileset dir="${appserver.lib}"&gt; &lt;include name="catalina-ant.jar"/&gt; &lt;include name="tomcat-coyote.jar"/&gt; &lt;include name="tomcat-util.jar"/&gt; &lt;/fileset&gt; &lt;fileset dir="${appserver.home}/bin"&gt; &lt;include name="tomcat-juli.jar"/&gt; &lt;/fileset&gt; &lt;/path&gt; </code></pre> <blockquote> <p>Where appserver.lib is the path to Tomcat 7’s lib directory and <code>appserver.home</code> is the path to Tomcat’s top level installed directory. This way Tomcat 7 is required on every box you build on.</p> <p>My personal preference is for 2 above.</p> <p>Now that your Ant script can see the Catalina-Ant JARs you need to tell it what tasks are available. These are most if not all of the tasks that are available to Ant.</p> </blockquote> <pre><code>&lt;taskdef name="catalina-deploy" classname="org.apache.catalina.ant.DeployTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-list" classname="org.apache.catalina.ant.ListTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-reload" classname="org.apache.catalina.ant.ReloadTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-findleaks" classname="org.apache.catalina.ant.FindLeaksTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-resources" classname="org.apache.catalina.ant.ResourcesTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-start" classname="org.apache.catalina.ant.StartTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-stop" classname="org.apache.catalina.ant.StopTask" classpathref="catalina-ant-classpath"/&gt; &lt;taskdef name="catalina-undeploy" classname="org.apache.catalina.ant.UndeployTask" classpathref="catalina-ant-classpath"/&gt; </code></pre> <blockquote> <p>Finally you need a set of tasks that actually do the work. Although, as you can see above, there are a few tasks I only tend to use the following ones:</p> </blockquote> <pre><code>&lt;target name = "stop-webapp"&gt; &lt;catalina-stop url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}" failonerror="false"/&gt; &lt;/target&gt; &lt;target name = "start-webapp"&gt; &lt;catalina-start url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}"/&gt; &lt;/target&gt; &lt;target name = "undeploy-webapp"&gt; &lt;catalina-undeploy url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}" failonerror="false"/&gt; &lt;/target&gt; &lt;target name = "deploy-webapp"&gt; &lt;catalina-deploy url="${tomcat.manager.url}" username="${tomcat.username}" password="${tomcat.password}" path="/${webapp.name}" war="file:${war.file}"/&gt; &lt;/target&gt; </code></pre> <blockquote> <p><code>tomcat.manager.url</code> is the URL where Tomcat manager lives. This is another of the changes from Tomcat 6 to Tomcat 7. Usually this will be: <code>http://:8080/manager/text</code>.</p> <p><code>Tomcat.username</code> and <code>Tomcat.password</code> are the user name and password for Tomcat manager.</p> <p><code>webapp.name</code> is the name of the Tomcat application that you are deploying.</p> <p><code>war.file</code> is the path the Tomcat application you are deploying’s WAR file.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload