Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Ant, Maven and Other Build Tools and the fly likes  How to deploy war file automatically in tomcat server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark " How to deploy war file automatically in tomcat server" Watch " How to deploy war file automatically in tomcat server" New topic
Author

How to deploy war file automatically in tomcat server

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,

I am able to write ant script(build.xml) for creating war file. Same war file if I deploy manually in the tomcat server it is working.

But my doubt is how to write the script which is automatically deploy in tomcat server after creating war file.

It would be grateful if you have provide me any suggestion/advice for the needful

Thanks and Regards,
Sumanta Panda
Gautam Velpula
Greenhorn

Joined: Aug 04, 2008
Posts: 13
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war"
webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>


add a target like this.
Hope this answers your question
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear Gautam,

Thanks for your suggestion.

That means in the "{deploy.path}" i have to mention my tomcat path "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps"

Please confirm.

Thanks for your time.

Regards,
Sumanta


Gautam Velpula
Greenhorn

Joined: Aug 04, 2008
Posts: 13
yes. That is correct
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sumanta, I would suggest to use the Tomcat Manager http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant
 
wood burning stoves
 
subject: How to deploy war file automatically in tomcat server
 
Similar Threads
create a war file
Configuring Tomcat5.5 in Eclipse3.6
deploying to Websphere 5.1 from the ant acript
JSP error using tomcat
when configure tomcat new Context tomcat creates me 2 web apps