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

Jetty/Feature/WebAppProvider



Introduction

The WebAppProvider is for static deployment of standard WAR files and webapps with little or no Jetty specific customization. For hot deployment of customized contexts, use the Context Provider.

Feature

The basic operation of WebAppProvider is to scan a directory at startup for WAR files or webapp directories and the deploy the webapplications found. Typically this is done from a jetty.xml style file, in the jetty distribution this file is called jetty-webapps.xml:

 <Configure id="Server" class="org.eclipse.jetty.server.Server">
    <Ref id="DeploymentManager">
          <Call id="webappprovider" name="addAppProvider">
            <Arg>
              <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
                <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
                <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
                <Set name="scanInterval">1</Set>
                <Set name="contextXmlDir"><Property name="jetty.home" default="." />/contexts</Set>
		<Set name="extractWars">true</Set>
              </New>
            </Arg>
          </Call>
    </Ref>
</Configure>

The WebAppProvider is added to the server as a LifeCycle. This simply means that the deployer will be started and stopped with the server. Ie when server.start() is called, then start will also be called on the deployer.

The context passed in is a reference to a HandlerContainer in which the discovered webapps will be deployed. This is normally an instance of ContextHandlerCollection.

The contextXmlDir points to a directory like that which is used in the ContextProvider, using this option will tell the webapp provider to check any webapp or war files in the monitored directory for an associated context file and if it finds one will defer to the ContextProvider for deploying the webapp. If none is found then this provider is used.

The monitoredDirName is a file path or URL to the directory to scan for webapplications. Zip files ending with .war or .zip are deployed. Directories not call CVS are also deployed. The basename of the war (eg foo from foo.war) or the directory name are used as the context path of the discovered webapps, unless the name is "root", in which case the context path of / is used.

The parentLoaderPriority parameter is a boolean that selects of the standard java parent first delegation classloading will be used or the servlet specification webapp classloading priority.

If the extract parameter is true, any packed war or zip files will first be extracted to a temporary directory before being deployed. This is advisable if there are uncompiled JSPs in the web apps.

If the allowDuplicates parameter is false, the discovered webapps will be checked against existing deployed webapps and will not be deployed if the same context path or war files is already deployed (perhaps by another deployer).

The defaultsDescriptor parameter allows an alternative webdefault.xml config file to be set on the discovered web applications. The webdefault.xml file is used to control the configuration of the JSP and Default servlets.

Back to the top