Jump to: navigation, search

Jetty/Howto/Deploy Web Applications

< Jetty‎ | Howto
Revision as of 02:40, 14 December 2010 by Tangfulin.gmail.com (Talk | contribs)



Introduction

Jetty can deploy web applications as war files (packed or unpacked), as provided or with overridden configuration, with static or hot deployment.

Webapps Deployment

The $JETTY_HOME/webapps directory is scanned at startup for webapplications to deploy:

  • The file foo.war will be deployed as a webapp at context /foo
  • The directory foo/ will be deployed at context /foo. If the directory has a WEB-INF subdirectory, it will be treated as servlet webapp, otherwise it will served only as static content.
  • If both a foo.war and a foo/ directory exists, then the one with the most recent last-modified date is used.
  • If the webapp is called root.war or the directory is called root/ then it will be deployed at the / context.

Webapp deployment was controlled the WebAppDeployer class. From 7.0.2 onwards this has been replaced by the WebAppProvider of the DeploymentManager.

See also older (but mostly relevant) Jetty-6 WebAppDeployer documentation.

Contexts Deployment

The $JETTY_HOME/contexts directory is scanned at runtime for context.xml files, that describe either:

  • a standard war file (or directory), plus additional configuration.
  • a custom jetty context.

Contexts deployment was controlled the ContextDeployer class. From 7.0.2 onwards this has been replaced by the ContextProvider of the DeploymentManager.

See also older (but mostly relevant) Jetty-6 ContextDeployer documentation.

Jetty Maven Plugin

If you develop your web application as a maven project, then it can be deployed in jetty with "mvn jetty:run" using the Jetty Maven Plugin

Maven lets you build your web applications by overlaying on other template web applications (eg Cometd) and will manage the transitive dependencies needed to populate WEB-INF/lib

OSGi web application bundle

TBD

Embedded Usage

Web applications can also be deployed into embedded jetty, either via direct configuration or via configuration of a deployer. For an example see the Embedding Jetty Tutorial