twitter
    !! Tell us what you want to Learn / Know !!

Deployments

Contexts:
       In talking about deployment of web applications, the concept of a Context is required to be understood. A Context is what Tomcat calls a web application.

In order to configure a Context within Tomcat a Context Descriptor is required. A Context Descriptor is simply an XML file that contains Tomcat related configuration for a Context, e.g naming resources or session manager configuration. In earlier versions of Tomcat the content of a Context Descriptor configuration was often stored within Tomcat's primary configuration file server.xml but this is now discouraged (although it currently still works).

Context Descriptors not only help Tomcat to know how to configure Contexts but other tools such as the Tomcat Manager and TCD (Tomcat Client Deployer) often use these Context Descriptors to perform their roles properly.

The locations for Context Descriptors are:
  1. $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml
  2. $CATALINA_BASE/webapps/[webappname]/META-INF/context.xml
Files in (1) are named [webappname].xml but files in (2) are named context.xml. If a Context Descriptor is not provided for a Context, Tomcat configures the Context using default values.

 Deploying on Tomcat startup:
          Navigate to the following location

          $CATALINA_HOME/webapps

          Place your application (war or exploded archive) in the webapps folder.


You can get the sample application here

Start the server by clicking on startup.bat


Navigate to the following location

$CATALNA_HOME/webapps

You can see that the war file you have deployed is extracted.


Now you can access your application at the following url

http://localhost:8080/suren

If everything went ok you should see the below screen.


If you got any error check the log files located in $CATALINA_HOME/logs

Deploying on a running Tomcat:
           It is possible to deploy web applications to a running Tomcat server.

If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the webapps. For this to work, the Host needs to have background processing enabled which is the default configuration.

The autoDeploy attribute is present in the server.xml file.

$CATALINA_HOME/conf/server.xml


The option will be true by default.

Start the server by clicking on startup.bat

Navigate to the following location

$CATALNA_HOME/webapps

Place your application in the webapps directory

Open the command prompt in which Tomcat is running.


You can see a message: Deploying web application archive suren.war

Now you can access your application at the following url

http://localhost:8080/suren


0 comments:

Post a Comment