Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure a webapps deployment directory in Jetty

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!

like image 211
Xandel Avatar asked Jan 19 '23 00:01

Xandel


2 Answers

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).

like image 107
blahdiblah Avatar answered Jan 25 '23 15:01

blahdiblah


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>
like image 43
Tony K. Avatar answered Jan 25 '23 15:01

Tony K.