tomcat deploy procedures

Upload: cooldudeiet

Post on 01-Mar-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 Tomcat Deploy Procedures

    1/4

    Tomcat Deploy Procedures: A Complete

    Guide to Web Application Deployment

    With Apache TomcatApache Tomcat offers users a lot of flexibility when deploying web applications. Tomcatis lightweight, and starts up in seconds, as opposed to the minutes it takes a stack-basedJava EE server to start, so traditional startup deploymentis feasible. owever, Tomcatalso supports a variety of hot deployment options, allowing users to roll out newapplications, or even update existing ones, while the server is still running.

    !n this guide, we"ll explore all the options available to you when deploying an applicationon your Tomcat server, from a simple startup deployment, to tools that can automate hotdeployment of your application across multiple running Tomcat servers.

    Tip#Tcatmakes deployment cycles take seconds instead of minutes. $eploymentpackages allow you to deploy the latest versions of all your applications to groups ofservers with a single click. %epository and rollback capabilities that integrate with&aven allow you to fully integrate Tcatinto your development cycle.

    Startup Deployment

    Also knowns as folder deployment, startup deployment is the easiest way to deploying aweb application to your server.

    To have Tomcat deploy an application automatically when it starts, simple copy either anuncompressed web application 'also known as an (exploded( application) or acompressed application, or *A%, to the app+ase folder specified in your ostconfiguration.

    *hen Tomcat starts, it will deploy all applications in the app+ase, in the following order#

    . Applications defined by ontextelements in either(ATA/!0A1+A2E3conf3server.xml( 'discouraged),(ATA/!0A1+A2E3conf34Engine0ame534ost0ame534Application0ame5.xml(,(or ATA/!0A1+A2E3webapps34Application0ame53&ETA-!063context.xml(

    7. 8ncompressed 'exploded) applications located in the app+ase without ontext$escriptors.

    9. doc+ase applications that are compressed in *A% files, along with *A%sassociated with an existing application, which will be used to automaticallyredeploy the application.

    To deploy a new application, Tomcat copies its directory structure to the relevant contextpath in its base webapps folder, creating directories as needed. !f the application provides

    http://www.mulesoft.com/tomcat-deploy#startuphttp://www.mulesoft.com/tomcat-deploy#hotdeployhttp://www.mulesoft.com/tomcat-deploy#startuphttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/misc/lbox-form.phphttp://www.mulesoft.com/misc/lbox-form.phphttp://www.mulesoft.com/misc/lbox-form.phphttp://www.mulesoft.com/tomcat-configurationhttp://www.mulesoft.com/tomcat-contexthttp://www.mulesoft.com/tomcat-contexthttp://www.mulesoft.com/tomcat-deploy#startuphttp://www.mulesoft.com/tomcat-deploy#hotdeployhttp://www.mulesoft.com/tomcat-deploy#startuphttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/misc/lbox-form.phphttp://www.mulesoft.com/misc/lbox-form.phphttp://www.mulesoft.com/tomcat-configurationhttp://www.mulesoft.com/tomcat-context
  • 7/25/2019 Tomcat Deploy Procedures

    2/4

    its own ontext.xml, this is copied to (ATA/!0A1+A2E3conf34Engine0ame534ost0ame534Application0ame5.xml(, provided this file does not already exist.

    Hot Deployment

    The big downfall of startup deployment is that it re:uires a full server restart to make anychanges to the application, or deploy new applications, even if the application doesn"thave any elements that would re:uire a restart for it to function.

    To remedy this situation, Tomcat provides a number of (hot deployment( options, whichsimply means that any deployments, redeployments, and ad;ustments to applications aremade while the server is still running, rather than re:uiring it to stop.

    There are a number of ways to use hot deployment with Tomcat. !n this section, we"ll goover the most common# ost auto$eploy,the Tomcat &anager, and the Tomcat lient$eployer.

    Host autoDeploy

    The most recent versions of Tomcat support a number of hot deployment features rightout of the box. These features are enabled on a per-ost basis, by setting the(auto$eploy( attribute to (true(.

    ere are some of the things you can do once you"ve enabled hot deployment#

    Automatically deploy exploded or compressed applications by placing them in the

    app+ase %e-deploy existing applications by copying an updated *A% file into the app+ase 8se *atched%esource elements to initiate application re-deploy whenever the

    defined resource is updated 'for example, *E+-!063web.xml)

    6or a complete list of auto$eploy-enabled hot deploy features, visit the Apachepro;ectwebsite.

    Deployment with Tomcat Manager

    The Tomcat &anager is a lightweight administrative tool included with all standarddistributions of Apache Tomcat, that provides a wide variety of deployment

    functionalities, including a number of hot deployment commands.

    &anager commands are sent in a standard 8%! format, as follows#

    http#334host5#4port53manager34command5

  • 7/25/2019 Tomcat Deploy Procedures

    3/4

    deployment from *A%, deployment from the app+ase, and even deployment by calling acontext.xml file that provides a doc+ase path.

    &anager can also remotely reload, undeploy 'careful, this means delete), start, and stopapplications.

    To make sure that Tomcat is secure out of the box, &anager and its features are disabledby default, and it takes more than a little wrangling to get it up and running.

    6or more information about using the &anager application on your server, including a listof commands and some example usages, please check out our helpfulTomcat &anager=uide.

    Deployment with the Tomcat Client Deployer

    The Tomcat lient $eployer 'T$) is a multi-component Java package that uses a

    variety of technologies to validate, compile, compress, and deploy your web applications.T$ is basically a bundle of Ant tasks that execute functions of the Jasper J2> Engine,J$?, and atalina engine 'including the Tomcat &anager) to :uickly move applicationsfrom your hard drive to your running Tomcat server.

    T$ is not included with standard distributions of Tomcat. @ou can download itseparately from the Tomcat pro;ect site. @ou can decompress it anywhere you want itdoesn"t need to be in a Tomcat directory. !f you haven"t installed it already, you"ll alsoneed to download and install Apache Antin order for T$ to run. 0ote that aconfigured, running instance of the Tomcat &anager application is re:uired for T$ towork.

    To deploy an application using T$, you will need to create and edit a file named(deployer.properties(, which should be located in the root directory of the T$ package.This file will look something like this, substituting 4values5 and BvariablesC#

    buildDBbuildC3webapp3BpathC

    webappD4path3to3target3exploded3application5

    pathD4$esiredontext>ath5

    urlD4http#334host5#4port53path3to3manager3webapp5

    usernameD48ser*ith&anager%ole5

    passwordD4Tomcat&anager>assword5

    nce you have configured this file, run T$ with the included Ant script. The defaulttarget, (compile(, will validate and compile the web application as a *A% file at the

    http://www.mulesoft.com/tomcat-managerhttp://www.mulesoft.com/tomcat-managerhttp://ant.apache.org/http://www.mulesoft.com/tomcat-managerhttp://ant.apache.org/
  • 7/25/2019 Tomcat Deploy Procedures

    4/4

    specified (build( location. ther targets with self-explanatory features include deploy,undeploy, start, reload, and stop.

    ther Hot Deployment Scenarios

    Aside from the three basic hot deployment methods, there are a few other ways you maywant to hot deploy to Tomcat.

    !n this section, we"ll learn how to set up an !ntegrated $evelopment Environmentto hotdeploy all changes to your Tomcat server, and look at how to deal with the complexproblem of hot deployment across multiple serversin a production environment.

    Hot Deployment to Tomcat with an !D"

    !ntegrated $evelopment Environments can speed up many aspects of Java webapplication development, including deployment of changes to the server.

    Thanks to Tomcat"s native support for hot deployment, getting Tomcat to updateapplications with your changes as you make them is a deceptively simple problem. Thereal hassle isn"t getting Tomcat to hot deploy changes - it"s getting your !$E talking toTomcat. ere"s a simple step-by-step guide#

    . onfigure your !$E to recogniFe Tomcat as a server environment. Thanks toTomcat"s popularity, most !$Es offer plug-ins adding Tomcat support to theirenvironment. 6or an example of this, check out Tomcat Eclipse, our simple,illustrated guide to using Tomcat in con;unction with the popular Eclipse !$E.

    7. =ive your !$E write-access to your application"s (*E+-!063classes( directory.

    9. onfigure Tomcat to reload classes when they are changed, by setting the(reloadable( attribute to (true( for the relevant ontext and *eb-App elements inyour Tomcat configuration files.

    http://www.mulesoft.com/tomcat-deploy#idehttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/tomcat-eclipsehttp://www.mulesoft.com/tomcat-deploy#idehttp://www.mulesoft.com/tomcat-deploy#Tcat-Serverhttp://www.mulesoft.com/tomcat-eclipse