You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bo Xu <bo...@gmail.com> on 2006/08/03 20:14:08 UTC

can not install a web application to a remote tomcat web server by Ant

Hi all, 
I spent a whole day trying to use ant to  deploy an web app to a remote tomcat web server. 
I can use the "list" task, but that is not the case of the "deploy" task.

Is there anyone who can tell how to use  the "path", "war" and "localwar" attributes in the catalian ant  deploy task in details?
For example, I have a war file named say "myapp.war" in the dir of "c:\tmp",  and the webapp's name is "testwebapp", the tomcat is in /usr/local/tomcat/.

Thanks in advance!

Bo

Re: can not install a web application to a remote tomcat web server by Ant

Posted by Nicholas Sushkin <ns...@openfinance.com>.
On Thursday 03 August 2006 14:14, Bo Xu wrote: 

> Hi all,
> I spent a whole day trying to use ant to  deploy an web app to a remote
> tomcat web server. I can use the "list" task, but that is not the case of
> the "deploy" task.
>
> Is there anyone who can tell how to use  the "path", "war" and "localwar"
> attributes in the catalian ant  deploy task in details? For example, I
> have a war file named say "myapp.war" in the dir of "c:\tmp",  and the
> webapp's name is "testwebapp", the tomcat is in /usr/local/tomcat/.
>

Bo, 

Assuming your remote tomcat5 is serving on host ${deploy.host} and port 
${deploy.port} and your tomcat user with user id and password of 
${deploy.username} and ${deploy.password} has a manager role, try something 
like this:

   <property name="tomcat-home" location="/usr/local/tomcat"/>
   <property name="instance" value="testwebapp"/>
   <property name="deploy.path" value="/testwebapp"/>
   <property name="dist" location="/tmp"/>
   <property name="war.name" value="myapp.war"/>
   <property name="deploy.url" value="http://${deploy.host}:
${deploy.port}/manager"/>
   

    <path id="deployer.classpath">
      <pathelement location="${tomcat.home}/server/lib/catalina-ant.jar"/>
      <pathelement 
location="${tomcat.home}/common/lib/jasper-compiler.jar"/>
      <pathelement location="${tomcat.home}/common/lib/jasper-runtime.jar"/>
      <pathelement location="${tomcat.home}/common/lib/servlet-api.jar"/>
      <pathelement 
location="${tomcat.home}/common/lib/commons-logging.jar"/>
    </path>
    <!-- define deployer tasks -->
    <taskdef resource="org/apache/catalina/ant/catalina.tasks" 
classpathref="deployer.classpath"/>

  <target name="deploy" description="Install web application"
          depends="war">
    <echo message="Deploying ${instance} instance of ${app} to 
${deploy.instance} tomcat at ${deploy.host}:
${deploy.port}/${deploy.path}"/>
    <deploy url="${deploy.url}"
            username="${deploy.username}" password="${deploy.password}"
            path="${deploy.path}" war="${dist}/${war.name}"/>
  </target>

  <target name="undeploy" description="Undeploy web application">
    <echo message="Undeploying ${instance} instance of ${app} from 
${deploy.instance} tomcat at ${deploy.host}:
${deploy.port}/${deploy.path}"/>
    <undeploy url="${deploy.url}" username="${deploy.username}" 
password="${deploy.password}"
            path="${deploy.path}"/>
  </target>

-- 
Nicholas Sushkin, Senior Software Engineer
Open Finance

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org