Jump to: navigation, search

Difference between revisions of "Jetty/Howto/Deploy Web Applications"

< Jetty‎ | Howto
m
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Jetty Howto  
 
{{Jetty Howto  
| introduction = TBD
+
| introduction = Jetty can deploy web applications as WAR files (packed or unpacked), as provided or with overridden configuration, and with static or hot deployment.
| steps =
+
 
}}
 
}}
 +
== Deploying Webapps ==
 +
Jetty scans its <tt>$JETTY_HOME/webapps</tt> directory at startup for web applications to deploy:
 +
* It deploys the file <tt>foo.war</tt>  as a webapp at context <tt>/foo</tt>.
 +
* It deploys the directory <tt>foo/</tt>  at context <tt>/foo</tt>. If the directory has a <tt>WEB-INF</tt> subdirectory, Jetty treats it as a servlet webapp, otherwise Jetty serves it only as static content.
 +
* If both a <tt>foo.war</tt> and a <tt>foo/</tt> directory exist, Jetty uses the one with the most recent last-modified date.
 +
* If the webapp is called <tt>root.war</tt> or the directory is called <tt>root/</tt> then Jetty deploys it at the / context.
 +
* If the <tt>contextXmlDir</tt> option is used and a <tt>foo.xml</tt> file exists in that dir, the WebAppProvider defers to the Contexts Provider for actual webapp deployment.
 +
 +
Formerly the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/WebAppDeployer.html WebAppDeployer] class controlled webapp deployment.  With Jetty version 7.0.2 and later, the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/providers/WebAppProvider.html WebAppProvider] of the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/DeploymentManager.html DeploymentManager] controls web app deployment..
 +
 +
See also older (but mostly relevant) [http://docs.codehaus.org/display/JETTY/WebAppDeployer Jetty-6 WebAppDeployer] documentation.
 +
 +
== Deploying Contexts ==
 +
Jetty scans the <tt>$JETTY_HOME/contexts</tt> directory at runtime for <tt>context.xml</tt> files that describe either:
 +
* a standard WAR file (or directory), plus additional configuration.
 +
* a custom Jetty context.
 +
 +
Formerly the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/ContextDeployer.html ContextDeployer] class contolled contexts deployment.  With Jetty version 7.0.2 and later, the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/providers/ContextProvider.html ContextProvider] of the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/DeploymentManager.html DeploymentManager] controls contexts deployment.
 +
 +
See also older (but mostly relevant) [http://docs.codehaus.org/display/JETTY/ContextDeployer Jetty-6 ContextDeployer] documentation.
 +
 +
== Jetty Maven Plugin ==
 +
If you develop your web application as a Maven project, you can deploy it in Jetty with <tt>mvn jetty:run</tt> using the [[Jetty/Feature/Jetty_Maven_Plugin|Jetty Maven Plugin]].
 +
 +
Maven lets you build your web applications by overlaying on other template web applications
 +
(for example, [http://cometd.org/documentation/howtos/primer Cometd]) and manages the transitive dependencies needed to populate WEB-INF/lib.
 +
 +
== OSGi web application bundle ==
 +
TBD
 +
 +
== Using Embedded Jetty ==
 +
You can also deploy web applications into embedded Jetty, either via direct configuration or via configuration of a deployer.  For an example see the [[Jetty/Tutorial/Embedding_Jetty|Embedding Jetty Tutorial]].

Revision as of 15:43, 28 April 2011



Introduction

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

Deploying Webapps

Jetty scans its $JETTY_HOME/webapps directory at startup for web applications to deploy:

  • It deploys the file foo.war as a webapp at context /foo.
  • It deploys the directory foo/ at context /foo. If the directory has a WEB-INF subdirectory, Jetty treats it as a servlet webapp, otherwise Jetty serves it only as static content.
  • If both a foo.war and a foo/ directory exist, Jetty uses the one with the most recent last-modified date.
  • If the webapp is called root.war or the directory is called root/ then Jetty deploys it at the / context.
  • If the contextXmlDir option is used and a foo.xml file exists in that dir, the WebAppProvider defers to the Contexts Provider for actual webapp deployment.

Formerly the WebAppDeployer class controlled webapp deployment. With Jetty version 7.0.2 and later, the WebAppProvider of the DeploymentManager controls web app deployment..

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

Deploying Contexts

Jetty scans the $JETTY_HOME/contexts directory at runtime for context.xml files that describe either:

  • a standard WAR file (or directory), plus additional configuration.
  • a custom Jetty context.

Formerly the ContextDeployer class contolled contexts deployment. With Jetty version 7.0.2 and later, the ContextProvider of the DeploymentManager controls contexts deployment.

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

Jetty Maven Plugin

If you develop your web application as a Maven project, you can deploy it 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 (for example, Cometd) and manages the transitive dependencies needed to populate WEB-INF/lib.

OSGi web application bundle

TBD

Using Embedded Jetty

You can also deploy web applications into embedded Jetty, either via direct configuration or via configuration of a deployer. For an example see the Embedding Jetty Tutorial.