Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

< Jetty‎ | Howto
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{Jetty Howto  
 
{{Jetty Howto  
| introduction = Jetty can deploy web applications as war files (packed or unpacked), as provided or with overridden configuration, with static or hot deployment.
+
| introduction =  
 +
 
 +
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/configuring-deployment.html}}
 +
 
 +
Jetty can deploy web applications as WAR files (packed or unpacked), as provided or with overridden configuration, and with static or hot deployment.
 
}}
 
}}
== Webapps Deployment ==
+
== Deploying Webapps ==
The $JETTY_HOME/webapps directory is scanned at startup for webapplications to deploy:
+
Jetty scans its <tt>$JETTY_HOME/webapps</tt> directory at startup for web applications to deploy:
* The file foo.war will be deployed as a webapp at context /foo
+
* It deploys the file <tt>foo.war</tt>  as a webapp at context <tt>/foo</tt>.
* 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.
+
* 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 foo.war and a foo/ directory exists, then the one with the most recent last-modified date is used.
+
* 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 root.war or the directory is called root/ then it will be deployed at the / context.
+
* If the webapp is called <tt>root.war</tt> or the directory is called <tt>root/</tt> then Jetty deploys it at the / context.
* Note: if the contextXmlDir option is used an a foo.xml file exists in that dir, the WebAppProvider will defer to the Contexts deployer for actual webapp deployment.
+
* 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.
  
Webapp deployment was controlled the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/WebAppDeployer.html WebAppDeployer] class.  From 7.0.2 onwards this has been replaced by 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].
+
Formerly the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/WebAppDeployer.html WebAppDeployer] class controlled webapp deploymentWith 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.
 
See also older (but mostly relevant) [http://docs.codehaus.org/display/JETTY/WebAppDeployer Jetty-6 WebAppDeployer] documentation.
  
== Contexts Deployment ==
+
== Deploying Contexts ==
The $JETTY_HOME/contexts directory is scanned at runtime for context.xml files, that describe either:
+
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 standard WAR file (or directory), plus additional configuration.
* a custom jetty context.
+
* a custom Jetty context.
  
Contexts deployment was controlled the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/ContextDeployer.html ContextDeployer] class.  From 7.0.2 onwards this has been replaced by 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].
+
Formerly the [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/deploy/ContextDeployer.html ContextDeployer] class contolled contexts deploymentWith 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.
 
See also older (but mostly relevant) [http://docs.codehaus.org/display/JETTY/ContextDeployer Jetty-6 ContextDeployer] documentation.
  
 
== Jetty Maven Plugin ==
 
== Jetty Maven Plugin ==
If you develop your web application as a maven project, then it can be deployed in jetty
+
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]].
with "mvn jetty:run" using the [[/Jetty/Feature/Jetty_Maven_Plugin|Jetty Maven Plugin]]
+
  
 
Maven lets you build your web applications by overlaying on other template web applications  
 
Maven lets you build your web applications by overlaying on other template web applications  
(eg [http://cometd.org/documentation/howtos/primer Cometd]) and will manage the transitive dependencies needed to populate WEB-INF/lib
+
(for example, [http://cometd.org/documentation/howtos/primer Cometd]) and manages the transitive dependencies needed to populate WEB-INF/lib.
  
 
== OSGi web application bundle ==
 
== OSGi web application bundle ==
 
TBD
 
TBD
  
== Embedded Usage ==
+
== Using Embedded Jetty ==
Web applications can also be deployed 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]]
+
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]].

Latest revision as of 15:02, 23 April 2013



Introduction

Warning2.png
Jetty 7 and Jetty 8 are now EOL (End of Life)




THIS IS NOT THE DOCUMENTATION YOU ARE LOOKING FOR!!!!!






All development and stable releases are being performed with Jetty 9 and Jetty 10.






This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub






Direct Link to updated documentation: http://www.eclipse.org/jetty/documentation/current/configuring-deployment.html


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.

Back to the top