How to configure a webapps deployment directory in Jetty

16,118

Solution 1

Why not just put the unpacked war file in webapps/?

As their docs say, if Jetty finds a directory in $JETTY_HOME/webapps/ it will happily deploy it as a servlet webapp. Then you can adjust the properties file without changing any Jetty settings.

This also means that you don't have to worry about Jetty overwriting any changes to property files when you have a new version of the app (though you still have to be careful about that).

Solution 2

I know this question is old, but I wanted an answer to this that was a configuration parameter, not an unpacked WAR solution. The configuration solution is to add the following parameter to the WebAppProvider (in 8.1.8, this is in jetty-webapps.xml):

<Set name="tempDir"><New class="java.io.File"><Arg>/usr/local/jetty-8.1.8/work</Arg></New></Set>

so that the overall config file reads something like:

<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>
                <Set name="tempDir"><New class="java.io.File"><Arg>/usr/local/jetty-8.1.8/work</Arg></New></Set>
              </New>
            </Arg>
          </Call>
    </Ref>
</Configure>
Share:
16,118
Xandel
Author by

Xandel

Updated on June 04, 2022

Comments

  • Xandel
    Xandel about 2 years

    This must be a dead simple answer but one I just can't seem to find!

    I've just started using Jetty 7.0.2 on CentOS 5.5 and have deployed a webapp with the default settings (by just placing my WAR file in the /webapps directory). When Jetty starts up, it extracts the war into the /tmp/jetty {something-warfilename-etc} directory.

    I understand that Jetty has loads of custom configuration that can be implemented, for now, however, I am just interested in setting the location for the extracted war files so that I can modify .properties files etc on the fly safely.

    Thanks in advance!

  • Xandel
    Xandel almost 13 years
    Hits head against desk You know when you're searching so hard for something that you expect to be complicated, meanwhile the simplest solution is sitting right in front of you? Well, this was that for me. :) Thanks blahdiblah.
  • Roman Starkov
    Roman Starkov over 11 years
    If you do this and you just get a 404 as if you didn't put anything anywhere... this might be because you're running under Java Service Wrapper and you didn't set jetty.home.
  • Rahul Taneja
    Rahul Taneja almost 10 years
    <Set name="tempDir"><New class="java.io.File"><Arg>/usr/local/jetty-8.1.8/work</Arg><‌​/New></Set> did not help me, I put this line in jetty-webapps.xml , but Jetty still deploys the web app in System Temp Directory. Could you please tell me if there is anything which is required to be set aside of it?
  • Rahul Taneja
    Rahul Taneja almost 10 years
    @blahdiblah I am not able to deploy the web apps in my desired location, any help related to it would be appreciated. I have tried to set the Temp Directory in jetty-webapps.xml and also I tried to configure Temp Directory via configureTempDirectory of class WebInfConfiguration in Jetty but of no respite. could you please help me in this context?