Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Good tutorial on Ant/Webapplications/Tomcat

Thread view: 
Gerbrand - 23 Aug 2006 18:39 GMT
Hello,

I want to set up a Ant build.xml file for webapplications.
I want to be able to create .war files automatically, and deploy them to
tomcat.

With ant, I have experience, and I know tomcat.
Can anyone point me to a good tutoral or website with documention how to
do this?
The website of ant is not very descriptive and using google I found lots
of documention, but all seem incomplete or out-dated.
Mindundi - 23 Aug 2006 22:56 GMT
war ant task documentation in Ant manual:

http://ant.apache.org/manual/CoreTasks/war.html

An example I did some time ago:

<target name="dist" depends="compile ,javadoc">
 <war file="${dist.home}/${app.name}.war"
webxml="${web.home}/WEB-INF/web.xml">
   <fileset dir="${build.home}">
     <exclude name="**/web.xml" />
     <exclude name="**/*.java" />
     <exclude name="**/*.class" />
   </fileset>
   <lib dir="${basedir}/lib"/>
   <classes dir="${build.home}/WEB-INF/classes">
     <exclude name="**/*.java"/>
   </classes>
 </war>
</target>

Note the proper filesets will depend on your environment.

Tomcat tasks examples:

<taskdef name="deploy"   classname="org.apache.catalina.ant.DeployTask"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>

<target name="install" depends="dist">
    <deploy url="${manager.url}"
       username="${manager.username}"
       password="${manager.password}"
           path="${app.path}"
            war="${dist.home}/action.war"/>
   </target>

<target name="remove">
    <undeploy url="${manager.url}"
         username="${manager.username}"
         password="${manager.password}"
             path="${app.path}"/>
</target>

-All is configured with a build.properties which assigns ${xxx}.
-You must include catalina-ant.jar (in Tomcat's server/lib folder) in your
classpath
-To remove an application, it's better to stop it before, with the stop task
(there are also start, list,...)
-Tomcat docs (not much) about its Ant tasks:
http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%2
0Commands%20With%20Ant

-Sometimes one or more webapp jars get locked and the remove undeploy task
doesn't work properly if you don't restart Tomcat. In that case, change
Tomcat's context.xml to <context antiJARLocking="true"> ... </context> to
prevent this to happen (only in development, as it will slow down things a
bit)

> Hello,
>
[quoted text clipped - 7 lines]
> The website of ant is not very descriptive and using google I found lots
> of documention, but all seem incomplete or out-dated.
Gerbrand - 27 Aug 2006 20:59 GMT
Mindundi schreef:
> war ant task documentation in Ant manual:
>
> http://ant.apache.org/manual/CoreTasks/war.html

Hi,

Many thanks, this documentation seems very useful.
Arne Vajhøj - 24 Aug 2006 02:52 GMT
> I want to set up a Ant build.xml file for webapplications.
> I want to be able to create .war files automatically, and deploy them to
[quoted text clipped - 5 lines]
> The website of ant is not very descriptive and using google I found lots
> of documention, but all seem incomplete or out-dated.

ant comes with docs.

My experience is that the documentation of tasks is sufficient
to use them.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.